2
votes

I'm trying to build an android app using visual studio community 2015. Basically right now, I'm just trying to build a test app so that I can check the IDE is working perfect for building my main app! But when I'm trying to build the app, it's showing me errors. Here is the output error message in VS -


    1>MSBUILD : cordova-build error : java.lang.UnsupportedClassVersionError: com/android/dx/command/Main : Unsupported major.minor version 52.0
    1>  java.lang.UnsupportedClassVersionError com/android/dx/command/Main : Unsupported major.minor version 52.0
    1>MSBUILD : cordova-build error :  at java.lang.ClassLoader.defineClass1(Native Method)
    1>      at java.lang.ClassLoader.defineClass1(Native Method)
    1>  :transformClassesWithDexForDebug FAILED
    1>MSBUILD : cordova-build error :  at java.lang.ClassLoader.defineClass(ClassLoader.java:800)
    1>      at java.lang.ClassLoader.defineClass(ClassLoader.java:800)
    1>MSBUILD : cordova-build error :  at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
    1>      at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
    1>MSBUILD : cordova-build error :  at java.net.URLClassLoader.defineClass(URLClassLoader.java:449)
    1>      at java.net.URLClassLoader.defineClass(URLClassLoader.java:449)
    1>MSBUILD : cordova-build error :  at java.net.URLClassLoader.access$100(URLClassLoader.java:71)
    1>      at java.net.URLClassLoader.access$100(URLClassLoader.java:71)
    1>MSBUILD : cordova-build error :  at java.net.URLClassLoader$1.run(URLClassLoader.java:361)
    1>      at java.net.URLClassLoader$1.run(URLClassLoader.java:361)
    1>MSBUILD : cordova-build error :  at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
    1>      at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
    1>MSBUILD : cordova-build error :  at java.security.AccessController.doPrivileged(Native Method)
    1>      at java.security.AccessController.doPrivileged(Native Method)
    1>MSBUILD : cordova-build error :  at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
    1>      at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
    1>MSBUILD : cordova-build error :  at java.lang.ClassLoader.loadClass(ClassLoader.java:425)
    1>      at java.lang.ClassLoader.loadClass(ClassLoader.java:425)
    1>MSBUILD : cordova-build error :  at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
    1>      at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
    1>MSBUILD : cordova-build error :  at java.lang.ClassLoader.loadClass(ClassLoader.java:358)
    1>      at java.lang.ClassLoader.loadClass(ClassLoader.java:358)
    1>MSBUILD : cordova-build error :  at sun.launcher.LauncherHelper.checkAndLoadMain(LauncherHelper.java:482)
    1>      at sun.launcher.LauncherHelper.checkAndLoadMain(LauncherHelper.java:482)
    1>MSBUILD : cordova-build error : Picked up _JAVA_OPTIONS: -Xmx512M
    1>  Picked up _JAVA_OPTIONS: -Xmx512M
    1>MSBUILD : cordova-build error : Exception in thread "main"
    1>  Exception in thread "main"
    1>
    1>MSBUILD : cordova-build error : FAILURE: Build failed with an exception.
    1>  FAILURE: Build failed with an exception.
    1>
    1>MSBUILD : cordova-build error : * What went wrong:
    1>  * What went wrong:
    1>MSBUILD : cordova-build error : Execution failed for task ':transformClassesWithDexForDebug'.
    1>  Execution failed for task ':transformClassesWithDexForDebug'.
    1>MSBUILD : cordova-build error : > com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command 'C:\Program Files (x86)\Java\jdk1.7.0_55\bin\java.exe'' finished with non-zero exit value 1
    1>  > com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command 'C:\Program Files (x86)\Java\jdk1.7.0_55\bin\java.exe'' finished with non-zero exit value 1
    1>
    1>MSBUILD : cordova-build error : * Try:
    1>  * Try:
    1>MSBUILD : cordova-build error : Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
    1>  Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
    1>
    1>  BUILD FAILED
    1>
    1>  Total time: 10.442 secs
    1>MSBUILD : cordova-build error : Error code 1 for command: cmd with args: /s,/c,""c:\users\eather ahmed\documents\visual studio 2015\Projects\Test Project\Test Project\platforms\android\gradlew" cdvBuildDebug -b "c:\users\eather ahmed\documents\visual studio 2015\Projects\Test Project\Test Project\platforms\android\build.gradle" -Dorg.gradle.daemon=true -Pandroid.useDeprecatedNdk=true"
    1>  Error code 1 for command: cmd with args: /s,/c,""c:\users\eather ahmed\documents\visual studio 2015\Projects\Test Project\Test Project\platforms\android\gradlew" cdvBuildDebug -b "c:\users\eather ahmed\documents\visual studio 2015\Projects\Test Project\Test Project\platforms\android\build.gradle" -Dorg.gradle.daemon=true -Pandroid.useDeprecatedNdk=true"
    ========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
    ========== Deploy: 0 succeeded, 0 failed, 0 skipped ==========

This is the full error message output in VS. Please help me to fix this issue and build my app successfully!

1

1 Answers

6
votes

From the error message, you are getting Unsupported major.minor version 52.0 error, which means you are using certain library, which requires a min version of Java SE 8.

So to fix the problem, you need to update your local JDK to at least 1.8 and configure Tools for Apache Cordova to use it. You can find the setting under Tools->Options->Tools for Apache Cordova->Environment Variable Overrides->JAVA_HOME.