Cordova command line not working with android


#1

meteor run ios works.

meteor run android give those errors :

=> Errors executing Cordova commands:

   While running Cordova app for platform Android with options --device:
   Error: Command failed: /myApp/.meteor/local/cordova-build/platforms/android/cordova/run --device
   Note: Some input files use or override a deprecated API.
   Note: Recompile with -Xlint:deprecation for details.
   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.
   Exception in thread "main" java.lang.UnsupportedClassVersionError: com/android/dx/command/Main : Unsupported major.minor version
   52.0
   at java.lang.ClassLoader.defineClass1(Native Method)
   at java.lang.ClassLoader.defineClass(ClassLoader.java:800)
   at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
   at java.net.URLClassLoader.defineClass(URLClassLoader.java:449)
   at java.net.URLClassLoader.access$100(URLClassLoader.java:71)
   at java.net.URLClassLoader$1.run(URLClassLoader.java:361)
   at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
   at java.security.AccessController.doPrivileged(Native Method)
   at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
   at java.lang.ClassLoader.loadClass(ClassLoader.java:425)
   at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
   at java.lang.ClassLoader.loadClass(ClassLoader.java:358)
   at sun.launcher.LauncherHelper.checkAndLoadMain(LauncherHelper.java:482)


   FAILURE: Build failed with an exception.

   * What went wrong:
   Execution failed for task ':transformClassesWithDexForDebug'.
   > com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command
   '/Library/Java/JavaVirtualMachines/jdk1.7.0_79.jdk/Contents/Home/bin/java'' finished with non-zero exit value 1

   * Try:
   Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
   Exception in thread "main" java.lang.UnsupportedClassVersionError: com/android/dx/command/Main : Unsupported major.minor version
   52.0
   at java.lang.ClassLoader.defineClass1(Native Method)
   at java.lang.ClassLoader.defineClass(ClassLoader.java:800)
   at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
   at java.net.URLClassLoader.defineClass(URLClassLoader.java:449)
   at java.net.URLClassLoader.access$100(URLClassLoader.java:71)
   at java.net.URLClassLoader$1.run(URLClassLoader.java:361)
   at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
   at java.security.AccessController.doPrivileged(Native Method)
   at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
   at java.lang.ClassLoader.loadClass(ClassLoader.java:425)
   at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
   at java.lang.ClassLoader.loadClass(ClassLoader.java:358)
   at sun.launcher.LauncherHelper.checkAndLoadMain(LauncherHelper.java:482)

   Error code 1 for command: /myApp/.meteor/local/cordova-build/platforms/android/gradlew with args:
   cdvBuildDebug,-b,/myApp/.meteor/local/cordova-build/platforms/android/build.gradle,-PcdvBuildArch=arm,-Dorg.gradle.daemon=true,-Pandroid.useDeprecatedNdk=true
   undefined
   at ChildProcess.exitCallback (/tools/utils/processes.js:151:23)
   at emitTwo (events.js:87:13)
   at ChildProcess.emit (events.js:172:7)
   at Process.ChildProcess._handle.onexit (internal/child_process.js:200:12)

/Users/fabien/.meteor/packages/meteor-tool/.1.4.1_2.1jlej5l++os.osx.x86_64+web.browser+web.cordova/mt-os.osx.x86_64/isopackets/cordova-support/npm/node_modules/meteor/promise/node_modules/meteor-promise/promise_server.js:165
      throw error;

#2

Solved :

Go to android studio configuration. SDK Platforms must have API level 23 checked (I had that). But that’s not enough. Go to SDK Tools, then check Show Package Details, expand the Android SDK Build-Tool 25 (or whatever version number) and make sure the 23.0.0 is checked. Even if it says it is obsolete.

The guide mention this :

Make sure to select SDK Platform API 23, because that is what the version of Cordova we bundle requires.

But says nothing about the Hidden package detail in the SDK Build-Tools. Since (let’s be honest) a fair share of us knows very little to nothing about native development and building, this would be worthy of a short mention in the guide.

( https://guide.meteor.com/mobile.html#installing-prerequisites-android )