Cannot run Cordova app using “Google Android Emula

2019-09-11 04:28发布

问题:

It shows the following error when running the application using "Google Android Emulator".

Severity Code Description Project File Line Suppression State Error java.lang.UnsupportedClassVersionError: com/android/dx/command/Main : Unsupported major.minor version 52.0 stapp 1

How to fix the issue for Cordova application? I installed both Java 1.7 and 1.8 on the PC.

Severity    Code    Description Project File    Line    Suppression State
Error       java.lang.UnsupportedClassVersionError: com/android/dx/command/Main : Unsupported major.minor version 52.0  stapp       1   
Error        at java.lang.ClassLoader.defineClass1(Native Method)   stapp       1   
Error        at java.lang.ClassLoader.defineClass(ClassLoader.java:800) stapp       1   
Error        at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142) stapp       1   
Error        at java.net.URLClassLoader.defineClass(URLClassLoader.java:449)    stapp       1   
Error        at java.net.URLClassLoader.access$100(URLClassLoader.java:71)  stapp       1   
Error        at java.net.URLClassLoader$1.run(URLClassLoader.java:361)  stapp       1   
Error        at java.net.URLClassLoader$1.run(URLClassLoader.java:355)  stapp       1   
Error        at java.security.AccessController.doPrivileged(Native Method)  stapp       1   
Error        at java.net.URLClassLoader.findClass(URLClassLoader.java:354)  stapp       1   
Error        at java.lang.ClassLoader.loadClass(ClassLoader.java:425)   stapp       1   
Error        at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)   stapp       1   
Error        at java.lang.ClassLoader.loadClass(ClassLoader.java:358)   stapp       1   
Error        at sun.launcher.LauncherHelper.checkAndLoadMain(LauncherHelper.java:482)   stapp       1   
Error       Picked up _JAVA_OPTIONS: -Xmx512M   stapp       1   
Error       Exception in thread "main"  stapp       1   
Error       java.lang.UnsupportedClassVersionError: com/android/dx/command/Main : Unsupported major.minor version 52.0  stapp       1   
Error        at java.lang.ClassLoader.defineClass1(Native Method)   stapp       1   
Error        at java.lang.ClassLoader.defineClass(ClassLoader.java:800) stapp       1   
Error        at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142) stapp       1   
Error        at java.net.URLClassLoader.defineClass(URLClassLoader.java:449)    stapp       1   
Error        at java.net.URLClassLoader.access$100(URLClassLoader.java:71)  stapp       1   
Error        at java.net.URLClassLoader$1.run(URLClassLoader.java:361)  stapp       1   
Error        at java.net.URLClassLoader$1.run(URLClassLoader.java:355)  stapp       1   
Error        at java.security.AccessController.doPrivileged(Native Method)  stapp       1   
Error        at java.net.URLClassLoader.findClass(URLClassLoader.java:354)  stapp       1   
Error        at java.lang.ClassLoader.loadClass(ClassLoader.java:425)   stapp       1   
Error        at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)   stapp       1   
Error        at java.lang.ClassLoader.loadClass(ClassLoader.java:358)   stapp       1   
Error        at sun.launcher.LauncherHelper.checkAndLoadMain(LauncherHelper.java:482)   stapp       1   
Error       Picked up _JAVA_OPTIONS: -Xmx512M   stapp       1   
Error       Exception in thread "main"  stapp       1   
Error       FAILURE: Build failed with an exception.    stapp       1   
Error       * What went wrong:  stapp       1   
Error       Execution failed for task ':transformClassesWithDexForDebug'.   stapp       1   
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  stapp       1   
Error       * Try:  stapp       1   
Error       Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.  stapp       1   
Error       Error code 1 for command: cmd with args: /s,/c,"D:\Users\....\myapp\platforms\android\gradlew cdvBuildDebug -b D:\Users\....\myapp\platforms\android\build.gradle -Dorg.gradle.daemon=true -Pandroid.useDeprecatedNdk=true" stapp       1