android studio笔记之编译运行错误

Posted 指尖上的人生

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了android studio笔记之编译运行错误相关的知识,希望对你有一定的参考价值。

错误类型:

Error:java.lang.UnsupportedClassVersionError: com/android/dx/command/Main : Unsupported major错误解决

Error:java.lang.UnsupportedClassVersionError: com/android/dx/command/Main : Unsupported major.minor version 52.0
Error: 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" 
Error:java.lang.UnsupportedClassVersionError: com/android/dx/command/Main : Unsupported major.minor version 52.0
Error: 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)
FAILURE: Build failed with an exception.
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" 
* What went wrong:
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 ‘C:\Program Files\Java\jdk1.7.0_67\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.

 

问题原因:android studio同jdk版本不匹配

解决方案:

1.重装Java JDK

2.buildToolsVersion"24.0.1"  降到  buildToolsVersion"23.0.3"  重新编译

    

 

以上是关于android studio笔记之编译运行错误的主要内容,如果未能解决你的问题,请参考以下文章

(推测)Android Studio 中的错误错误,但编译器和应用程序运行良好

在运行我的 Android Studio 项目时,Java 编译器给出了这个错误

用android studio运行weex项目错误汇总

[Android 11]使用Android Studio调试系统应用之Settings移植:签名部署,解决运行时错误

使用Android Studio调试系统应用之LiveTV:移植编译调试,一气呵成

Android Studio编译错误总结