安装Android studio后,创建了一个传说中的hello world,但是老是报错,其中一个错误就是:

Error:java.lang.UnsupportedClassVersionError: com/android/dx/command/Main : Unsupported major.minor version 52.0Error: at java.lang.ClassLoader.defineClass1(Native Method)Error: at java.lang.ClassLoader.defineClass(ClassLoader.java:800)Error:java.lang.UnsupportedClassVersionError: com/android/dx/command/Main : Unsupported major.minor version 52.0Error: at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)Error: at java.lang.ClassLoader.defineClass1(Native Method)Error: at java.net.URLClassLoader.defineClass(URLClassLoader.java:449)Error: at java.lang.ClassLoader.defineClass(ClassLoader.java:800)Error: at java.net.URLClassLoader.access$100(URLClassLoader.java:71)Error: at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)Error: at java.net.URLClassLoader$1.run(URLClassLoader.java:361)Error: at java.net.URLClassLoader.defineClass(URLClassLoader.java:449)Error: at java.net.URLClassLoader$1.run(URLClassLoader.java:355)Error: at java.net.URLClassLoader.access$100(URLClassLoader.java:71)Error:java.lang.UnsupportedClassVersionError: com/android/dx/command/Main : Unsupported major.minor version 52.0Error: at java.security.AccessController.doPrivileged(Native Method)Error: at java.lang.ClassLoader.defineClass1(Native Method)Error: at java.net.URLClassLoader$1.run(URLClassLoader.java:361)Error: at java.lang.ClassLoader.defineClass(ClassLoader.java:800)Error: at java.net.URLClassLoader.findClass(URLClassLoader.java:354)Error: at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)Error: at java.net.URLClassLoader$1.run(URLClassLoader.java:355)Error: at java.net.URLClassLoader.defineClass(URLClassLoader.java:449)Error: at java.lang.ClassLoader.loadClass(ClassLoader.java:425)Error: at java.net.URLClassLoader.access$100(URLClassLoader.java:71)Error: at java.security.AccessController.doPrivileged(Native Method)Error: at java.net.URLClassLoader$1.run(URLClassLoader.java:361)Error: at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)Error: at java.net.URLClassLoader$1.run(URLClassLoader.java:355)Error: at java.net.URLClassLoader.findClass(URLClassLoader.java:354)Error: at java.security.AccessController.doPrivileged(Native Method)Error: at java.lang.ClassLoader.loadClass(ClassLoader.java:358)Error: at java.net.URLClassLoader.findClass(URLClassLoader.java:354)Error: at java.lang.ClassLoader.loadClass(ClassLoader.java:425)Error: at java.lang.ClassLoader.loadClass(ClassLoader.java:425)Error: at sun.launcher.LauncherHelper.checkAndLoadMain(LauncherHelper.java:482)Error: at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)Error: at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)Error: at java.lang.ClassLoader.loadClass(ClassLoader.java:358)Error:Exception in thread "main" Error: at sun.launcher.LauncherHelper.checkAndLoadMain(LauncherHelper.java:482)Error: at java.lang.ClassLoader.loadClass(ClassLoader.java:358)Error:Exception in thread "main" Error: at sun.launcher.LauncherHelper.checkAndLoadMain(LauncherHelper.java:482):app:transformClassesWithDexForDebug FAILEDError:Exception in thread "main" Error:Execution failed for task ':app:transformClassesWithDexForDebug'.> com.android.build.api.transform.TransformException: java.lang.RuntimeException: com.android.ide.common.process.ProcessException: java.util.concurrent.ExecutionException: com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command 'E:/Java/jdk1.7.9/bin/java.exe'' finished with non-zero exit value 1Information:BUILD FAILEDInformation:Total time: 17.886 secsError:java.lang.UnsupportedClassVersionError: com/android/dx/command/Main : Unsupported major.minor version 52.0Error: at java.lang.ClassLoader.defineClass1(Native Method)Error: at java.lang.ClassLoader.defineClass(ClassLoader.java:800)Error: at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)Error: at java.net.URLClassLoader.defineClass(URLClassLoader.java:449)Error: at java.net.URLClassLoader.access$100(URLClassLoader.java:71)Error: at java.net.URLClassLoader$1.run(URLClassLoader.java:361)Error: at java.net.URLClassLoader$1.run(URLClassLoader.java:355)Error: at java.security.AccessController.doPrivileged(Native Method)Error: at java.net.URLClassLoader.findClass(URLClassLoader.java:354)Error: at java.lang.ClassLoader.loadClass(ClassLoader.java:425)Error: at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)Error: at java.lang.ClassLoader.loadClass(ClassLoader.java:358)Error: at sun.launcher.LauncherHelper.checkAndLoadMain(LauncherHelper.java:482)Error:Exception in thread "main"

这是构建版本太高所致:Gradle Scripts >>

build.gradle (Module app)

Change buildToolsVersion "24.0.0" to buildToolsVersion "23.0.3"

Logo

华为开发者空间,是为全球开发者打造的专属开发空间,汇聚了华为优质开发资源及工具,致力于让每一位开发者拥有一台云主机,基于华为根生态开发、创新。

更多推荐