Unable to build android with vanilla project


#1

I have tried to execute the simple “Get Started” tutorial, without edit any file, but simply using this command

$ npm install -g cordova ionic
$ ionic start test tabs
$ ionic platform add android

And all these 3 command work file. After i have run this

$ ionic build android

And the command fails with errors

:compileDebugJavaWithJavacNote: /Users/andreabersi/app/test/platforms/android/src/org/apache/cordova/splashscreen/SplashScreen.java uses or overrides a deprecated API.
Note: Recompile with -Xlint:deprecation for details.

:compileDebugNdk UP-TO-DATE
:compileDebugSources
:transformClassesWithDexForDebugException 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)

FAILED

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.

BUILD FAILED

Total time: 7.515 secs

I have NOT changed any into the vanilla project; i have an Android Studio with SDK API level 22, 23 and 24 enabled.

The $ java version show

java version "1.7.0_79"
Java™ SE Runtime Environment (build 1.7.0_79-b15)
Java HotSpot™ 64-Bit Server VM (build 24.79-b02, mixed mode)

What is broken? this is my first attempt with IONIC and Android :frowning:
Thank you in advance


#2

Same problem here. Is there a preferred version of JDK to use with ionic? already tried 7.0_79 and _80 (both x86 and x64), they all failed. Just to be clear, I altered JAVA_HOME in every trial.

The error occurs with the plain examples from ionic (blank, sidemenu and tabs):

“Execution failed for task ‘:transformClassesWithDexForDebug’.”

I tried adding " multiDexEnabled true" to my build.gradle, turns out the error is only delayed to arise with: “transformClassesWithMultidexListForDebug”.


#3

It is probably the Java version. Turns out ionic getting started page directs you to the Android platform installation process, which referes to an old version of java (java 7). JDK 8 can be downloaded from here:

http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html

I will test it when I get home, but that is most likely the reason.


#4

Ok
I have reinstall the JDK 8 and all work now
Thank you


#5

U saved my life. I was searching for days…


#6

this fixed my problem thank you


#7

Thanks so much! :smiley:
It fixed the problem for me as well
:+1: :+1: :+1: :ok_hand: :v:


#8

You save my life today :3 <3