Ionic run android gives error : Unsupported major.minor version 52.0

Hi all,

I am new to ionic and not able to understand following error, i am executing syntax from git bash… i have updated latest android SDK i.e API 23. also tried by removing android platform and added it again but still not working. Please look and help.

Thank you.

Error :

DESKTOP-D452L4L+Pritesh@DESKTOP-D452L4L MINGW64 /d/projects/ionic/todo
$ ionic run android

Running command: “C:\Program Files (x86)\nodejs\node.exe” D:\projects\ionic\todo \hooks\after_prepare\010_add_platform_class.js D:/projects/ionic/todo
add to body class: platform-android
ANDROID_HOME=C:\Program Files (x86)\Android\android-sdk
JAVA_HOME=C:\Program Files (x86)\Java\jdk1.7.0_79
No target specified, deploying to device ‘192.168.56.101:5555’.
:preBuild UP-TO-DATE
:preDebugBuild UP-TO-DATE
:checkDebugManifest
:CordovaLib:preBuild UP-TO-DATE
:CordovaLib:preDebugBuild UP-TO-DATE
:CordovaLib:compileDebugNdk UP-TO-DATE
:CordovaLib:compileLint
:CordovaLib:copyDebugLint UP-TO-DATE
:CordovaLib:mergeDebugProguardFiles UP-TO-DATE
:CordovaLib:packageDebugRenderscript UP-TO-DATE
:CordovaLib:checkDebugManifest
:CordovaLib:prepareDebugDependencies
:CordovaLib:compileDebugRenderscript UP-TO-DATE
:CordovaLib:generateDebugResValues UP-TO-DATE
:CordovaLib:generateDebugResources UP-TO-DATE
:CordovaLib:packageDebugResources UP-TO-DATE
:CordovaLib:compileDebugAidl UP-TO-DATE
:CordovaLib:generateDebugBuildConfig UP-TO-DATE
:CordovaLib:generateDebugAssets UP-TO-DATE
:CordovaLib:mergeDebugAssets UP-TO-DATE
:CordovaLib:processDebugManifest UP-TO-DATE
:CordovaLib:processDebugResources UP-TO-DATE
:CordovaLib:generateDebugSources UP-TO-DATE
:CordovaLib:compileDebugJavaWithJavac UP-TO-DATE
:CordovaLib:processDebugJavaRes UP-TO-DATE
:CordovaLib:transformResourcesWithMergeJavaResForDebug UP-TO-DATE
:CordovaLib:transformClassesAndResourcesWithSyncLibJarsForDebug UP-TO-DATE
:CordovaLib:mergeDebugJniLibFolders UP-TO-DATE
:CordovaLib:transformNative_libsWithMergeJniLibsForDebug UP-TO-DATE
:CordovaLib:transformNative_libsWithSyncJniLibsForDebug UP-TO-DATE
:CordovaLib:bundleDebug UP-TO-DATE
:prepareAndroidCordovaLibUnspecifiedDebugLibrary UP-TO-DATE
:prepareDebugDependencies
:compileDebugAidl UP-TO-DATE
:compileDebugRenderscript
:generateDebugBuildConfig
:generateDebugAssets UP-TO-DATE
:mergeDebugAssets UP-TO-DATE
:generateDebugResValues UP-TO-DATE
:generateDebugResources
:mergeDebugResources
:processDebugManifest
:processDebugResources
:generateDebugSources
:compileDebugJavaWithJavacNote: D:\Projects\ionic\todo\platforms\android\src\org \apache\cordova\splashscreen\SplashScreen.java uses or overrides a deprecated AP I.
Note: Recompile with -Xlint:deprecation for details.

:compileDebugNdk UP-TO-DATE
:compileDebugSources
:transformClassesWithDexForDebugjava.lang.UnsupportedClassVersionError: com/andr oid/dx/command/Main : Unsupported major.minor version 52.0
FAILED
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:800)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:14 2)
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)
Exception in thread “main”

FAILURE: Build failed with an exception.

  • What went wrong:
    Execution failed for task ‘:transformClassesWithDexForDebug’.

com.android.ide.common.process.ProcessException: org.gradle.process.internal.E xecException: Process ‘command ‘C:\Program Files (x86)\Java\jdk1.7.0_79\bin\java .exe’’ 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: 6.18 secs
java.lang.UnsupportedClassVersionError: com/android/dx/command/Main : Unsupporte d 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:14 2)
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)
Exception in thread “main”
Error: Error code 1 for command: cmd with args: /s,/c,“D:\projects\ionic\todo\pl atforms\android\gradlew cdvBuildDebug -b D:\projects\ionic\todo\platforms\androi d\build.gradle -PcdvBuildArch=x86 -Dorg.gradle.daemon=true -Pandroid.useDeprecat edNdk=true”

3 Likes

I solved this problem by changing the Android SDK Build-tools from version 24 to version 23.0.3

In Android Studio I uninstalled Android SDK Build-tools version 24, installed version 23.0.3 and then tried to build the android project with the ionic CLI, and it worked.

I am using jdk1.7.0_79

Thank you

29 Likes

@priteshpmehta Thanks.

Thanks a lot!, worked for me too, using jdk1.7.0_45. I hope someone (at Ionic ?) notices this problem because there can be a conflicting requirement to use the latest Android SDK Build-tools in Android Studio.

1 Like

Yes, same here. Unistalled SDK Build Tools 24.0.1 and it works again!

Thanks,

RGecy

Salvou o dia! Obrigado.

Thanks, this helped me too!!

Thanks a lot! It works for me too! I’m using jdk jdk1.7.0_09.

This also worked for me. Thanks!

You saved my day, THANKS A LOT @priteshpmehta

this solves the problem. thanks for the help

It worked for me too. I deleted the version 24 Android SDK Build tools using Android SDK manager and then I could do ionic build android without errors.

Thanks a lot!!! It solved my problem.

THANK YOU! This problem was driving me crazy.

“Another separate issue is that versions 24 and higher of the Android SDK Build-tools package require Java JDK 8 or higher.” So yeah it would not run with java 7 :slight_smile:

1 Like

Great! works… thank you so much!

It works for me too, thanks. Now the only problem is that, when I try to install the generated APK in an android phone, it says “there was an error while analysing the package”. Wonder how to solve that one now.

Thank You Pritesh … I Got same Issue … And Solved …

Why delete the v24 build? Just update the Java dev kit to 8+ from http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html

My default java Version was 1.7 (check withjava -version ).
But i already had 1.8 on my system, so i just had to change to $JAVA_HOME variable to make it work. No need to uninstall v24.

How to change $JAVA_HOME is described in this SO Article: