Building Android Cordova app on El Capitan fails


#1

Building my app on Meteor 1.1.0.3 used to work fine in Yosemite but after doing the following:

  • Upgraded to El Capitan GM
  • Updated to Java SDK 1.8.0_60

I get this:

/Users/Aram/.meteor/packages/meteor-tool/.1.1.4.ck0zjs++os.osx.x86_64+web.browser+web.cordova/mt-os.osx.x86_64/dev_bundle/lib/node_modules/fibers/future.js:278
						throw(ex);
						      ^
Error: ENOENT, readdir '/Users/Aram/Development/Work/Ewash/bac-estimator/app/.meteor/local/cordova-build/platforms/android/ant-build'
  at Object.Future.wait (/Users/Aram/.meteor/packages/meteor-tool/.1.1.4.ck0zjs++os.osx.x86_64+web.browser+web.cordova/mt-os.osx.x86_64/dev_bundle/lib/node_modules/fibers/future.js:398:15)
  at Object.wrapper (/Users/Aram/.meteor/packages/meteor-tool/.1.1.4.ck0zjs++os.osx.x86_64+web.browser+web.cordova/mt-os.osx.x86_64/tools/files.js:1350:24)
  at findApkPath (/Users/Aram/.meteor/packages/meteor-tool/.1.1.4.ck0zjs++os.osx.x86_64+web.browser+web.cordova/mt-os.osx.x86_64/tools/commands.js:965:30)
  at /Users/Aram/.meteor/packages/meteor-tool/.1.1.4.ck0zjs++os.osx.x86_64+web.browser+web.cordova/mt-os.osx.x86_64/tools/commands.js:950:21
  at Array.forEach (native)
  at Function._.each._.forEach (/Users/Aram/.meteor/packages/meteor-tool/.1.1.4.ck0zjs++os.osx.x86_64+web.browser+web.cordova/mt-os.osx.x86_64/dev_bundle/lib/node_modules/underscore/underscore.js:79:11)
  at buildCommand (/Users/Aram/.meteor/packages/meteor-tool/.1.1.4.ck0zjs++os.osx.x86_64+web.browser+web.cordova/mt-os.osx.x86_64/tools/commands.js:933:29)
  at Command.main.registerCommand._.extend.name [as func] (/Users/Aram/.meteor/packages/meteor-tool/.1.1.4.ck0zjs++os.osx.x86_64+web.browser+web.cordova/mt-os.osx.x86_64/tools/commands.js:746:12)
  at /Users/Aram/.meteor/packages/meteor-tool/.1.1.4.ck0zjs++os.osx.x86_64+web.browser+web.cordova/mt-os.osx.x86_64/tools/main.js:1363:23

    - - - - -

I have removed the ~/.meteor/android_bundle directory and reinstalled the android SDK, as well as removing the android platform local to the project and adding it back. Just to note, I’m not able to install the HAXM version properly as reported here, but the simulator seems to run fine.

Any ideas?


#2

Could you try this with Meteor 1.2? If it turns out there are indeed incompatibilities with El Capitan, these are unlikely to be fixed in the older Cordova and Android tools versions bundled with 1.1.0.3.


#3

Yep, I updated the app and packages to Meteor 1.2 and followed this guide to set up Android Studio and install the SDK. I removed the ANDROID_HOME environment variable and removed the android_bundle directory. I removed the platform from the app and added it back. On build I get this:

$ meteor build ../dist --server=http://yourbac.com.au
=> Errors executing Cordova commands:

   While building Cordova app for platform Android:
   Error:
   /Users/Aram/Development/Work/Ewash/bac-estimator/app/.meteor/local/cordova-build/platforms/android/cordova/build:
   Command failed with exit code 8 Error output:

   /Users/Aram/Development/Work/Ewash/bac-estimator/app/.meteor/local/cordova-build/platforms/android/cordova/node_modules/q/q.js:126
   throw e;
   ^
   Error code 1 for command:
   /Users/Aram/Development/Work/Ewash/bac-estimator/app/.meteor/local/cordova-build/platforms/android/gradlew with
   args:
   cdvBuildRelease,-b,/Users/Aram/Development/Work/Ewash/bac-estimator/app/.meteor/local/cordova-build/platforms/android/build.gradle,-Dorg.gradle.daemon=true
   at ChildProcess.whenDone
   (/Users/Aram/.meteor/packages/meteor-tool/.1.1.8.qtulmo++os.osx.x86_64+web.browser+web.cordova/mt-os.osx.x86_64/dev_bundle/lib/node_modules/cordova-lib/src/cordova/superspawn.js:139:23)
   at ChildProcess.emit (events.js:98:17)
   at maybeClose (child_process.js:766:16)
   at Socket.<anonymous> (child_process.js:979:11)
   at Socket.emit (events.js:95:17)
   at Pipe.close (net.js:466:12)

#4

Here’s the same error on a fresh Meteor 1.2 project:

Building Cordova app for platform Android
% Running command: /Users/Aram/Desktop/demo/.meteor/local/cordova-build/platforms/android/cordova/build --release
ANDROID_HOME=/Users/Aram/Library/Android/sdk \
JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.8.0_51.jdk/Contents/Home/jre
Running: /Users/Aram/Desktop/demo/.meteor/local/cordova-build/platforms/android/gradlew cdvBuildRelease -b /Users/Aram/Desktop/demo/.meteor/local/cordova-build/platforms/android/build.gradle -Dorg.gradle.daemon=true

ERROR: JAVA_HOME is set to an invalid directory: /Library/Java/JavaVirtualMachines/jdk1.8.0_51.jdk/Contents/Home/jre

Please set the JAVA_HOME variable in your environment to match the
location of your Java installation.


/Users/Aram/Desktop/demo/.meteor/local/cordova-build/platforms/android/cordova/node_modules/q/q.js:126
                    throw e;
                          ^
Error code 1 for command: /Users/Aram/Desktop/demo/.meteor/local/cordova-build/platforms/android/gradlew with args: cdvBuildRelease,-b,/Users/Aram/Desktop/demo/.meteor/local/cordova-build/platforms/android/build.gradle,-Dorg.gradle.daemon=true
% ERROR building one of the platforms: Error: /Users/Aram/Desktop/demo/.meteor/local/cordova-build/platforms/android/cordova/build: Command failed with exit code 8
You may not have the required environment or OS to build this project
=> Errors executing Cordova commands:

   While building Cordova app for platform Android:
   Error: /Users/Aram/Desktop/demo/.meteor/local/cordova-build/platforms/android/cordova/build: Command failed with
   exit code 8
   at ChildProcess.whenDone
   (/Users/Aram/.meteor/packages/meteor-tool/.1.1.8.qtulmo++os.osx.x86_64+web.browser+web.cordova/mt-os.osx.x86_64/dev_bundle/lib/node_modules/cordova-lib/src/cordova/superspawn.js:139:23)
   at ChildProcess.emit (events.js:98:17)
   at maybeClose (child_process.js:766:16)
   at Process.ChildProcess._handle.onexit (child_process.js:833:5)

Looks like something failing with the gradle tool. Is it possible to read verbose output for that?


#5

Could it be that you’ve installed the JRE (Java Runtime Environment) instead of the JDK (Java Development Kit)? At least that’s what your JAVA_HOME seems to suggest. That would also explain why Gradle isn’t working.


#6

Ah! You’re right it looks like that was it!
I changed it to this (excluding the jre) for anyone else having this issue:

/Library/Java/JavaVirtualMachines/jdk1.8.0_60.jdk/Contents/Home

Thanks for your help Martijn!


#7

Actually, it works on the plain app but fails on my larger app with this:

=> Errors executing Cordova commands:

   While building Cordova app for platform Android:
   Error:
   /Users/Aram/Development/Work/Ewash/bac-estimator/app/.meteor/local/cordova-build/platforms/android/cordova/build:
   Command failed with exit code 8 Error output:
   Note: Some input files use or override a deprecated API.
   Note: Recompile with -Xlint:deprecation for details.

   /Users/Aram/Development/Work/Ewash/bac-estimator/app/.meteor/local/cordova-build/platforms/android/src/org/apache/cordova/inappbrowser/InAppBrowser.java:120:
   error: cannot find symbol
   || Config.isUrlWhiteListed(url)) {
   ^
   symbol:   method isUrlWhiteListed(String)
   location: class Config
   Note: Some input files use or override a deprecated API.
   Note: Recompile with -Xlint:deprecation for details.
   Note: Some input files use unchecked or unsafe operations.
   Note: Recompile with -Xlint:unchecked for details.
   1 error

   FAILURE: Build failed with an exception.

   * What went wrong:
   Execution failed for task ':compileReleaseJava'.
   > Compilation failed; see the compiler error output for details.

   * Try:
   Run with --stacktrace option to get the stack trace. Run with --info or
   --debug option to get more log output.


   /Users/Aram/Development/Work/Ewash/bac-estimator/app/.meteor/local/cordova-build/platforms/android/cordova/node_modules/q/q.js:126
   throw e;
   ^
   Error code 1 for command:
   /Users/Aram/Development/Work/Ewash/bac-estimator/app/.meteor/local/cordova-build/platforms/android/gradlew
   with args:
   cdvBuildRelease,-b,/Users/Aram/Development/Work/Ewash/bac-estimator/app/.meteor/local/cordova-build/platforms/android/build.gradle,-Dorg.gradle.daemon=true
   at ChildProcess.whenDone
   (/Users/Aram/.meteor/packages/meteor-tool/.1.1.8.qtulmo++os.osx.x86_64+web.browser+web.cordova/mt-os.osx.x86_64/dev_bundle/lib/node_modules/cordova-lib/src/cordova/superspawn.js:139:23)
   at ChildProcess.emit (events.js:98:17)
   at maybeClose (child_process.js:766:16)
   at Socket.<anonymous> (child_process.js:979:11)
   at Socket.emit (events.js:95:17)
   at Pipe.close (net.js:466:12)

It looks like it failed to parse something in the InAppBrowser plugin? Perhaps my mobile-config file is outdated?


#8

It seems the version of the inappbrowser plugin you installed might be too old for the newer Cordova Android platform. You may want to try removing it and adding the latest version (1.0.1).