我正在尝试使用Visual Studio社区2015构建一个Android应用程序。基本上现在,我只是想构建一个测试应用程序,以便我可以检查IDE是否适合构建我的主应用程序!但是当我试图构建应用程序时,它会向我显示错误。这是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 ==========
这是VS中的完整错误消息输出。请帮我修复此问题并成功构建我的应用程序!
答案 0 :(得分:6)
从错误消息中,您收到Unsupported major.minor version 52.0
错误,这意味着您正在使用某个库,这需要最低版本的Java SE 8.
因此,要解决此问题,您需要将本地JDK更新到至少1.8并配置Apache Cordova工具才能使用它。您可以在Tools->Options->Tools for Apache Cordova->Environment Variable Overrides->JAVA_HOME
下找到该设置。