gpt4 book ai didi

android - Gradle构建错误

转载 作者:行者123 更新时间:2023-12-03 06:33:58 25 4
gpt4 key购买 nike

我正在尝试运行我的第一个android studio项目(基本 Activity ),但是我总是面临很多错误,这是输出:(build.gradle文件也附在下面)

Information:Gradle tasks [:app:clean, :app:generateDebugSources, :app:generateDebugAndroidTestSources, :app:mockableAndroidJar,

:app:prepareDebugUnitTestDependencies, :app:assembleDebug] :app:clean :app:preBuild UP-TO-DATE :app:preDebugBuild UP-TO-DATE :app:checkDebugManifest :app:preReleaseBuild UP-TO-DATE :app:prepareComAndroidSupportAnimatedVectorDrawable2340Library :app:prepareComAndroidSupportAppcompatV72340Library :app:prepareComAndroidSupportDesign2340Library :app:prepareComAndroidSupportRecyclerviewV72340Library :app:prepareComAndroidSupportSupportV42340Library :app:prepareComAndroidSupportSupportVectorDrawable2340Library :app:prepareDebugDependencies :app:compileDebugAidl :app:compileDebugRenderscript :app:generateDebugBuildConfig :app:mergeDebugShaders :app:compileDebugShaders :app:generateDebugAssets :app:mergeDebugAssets :app:generateDebugResValues UP-TO-DATE :app:generateDebugResources :app:mergeDebugResources :app:processDebugManifest :app:processDebugResources :app:generateDebugSources :app:preDebugAndroidTestBuild UP-TO-DATE :app:prepareDebugAndroidTestDependencies :app:compileDebugAndroidTestAidl :app:processDebugAndroidTestManifest :app:compileDebugAndroidTestRenderscript :app:generateDebugAndroidTestBuildConfig :app:mergeDebugAndroidTestShaders :app:compileDebugAndroidTestShaders :app:generateDebugAndroidTestAssets :app:mergeDebugAndroidTestAssets :app:generateDebugAndroidTestResValues UP-TO-DATE :app:generateDebugAndroidTestResources :app:mergeDebugAndroidTestResources :app:processDebugAndroidTestResources :app:generateDebugAndroidTestSources :app:mockableAndroidJar UP-TO-DATE :app:preDebugUnitTestBuild UP-TO-DATE :app:prepareDebugUnitTestDependencies :app:incrementalDebugJavaCompilationSafeguard :app:compileDebugJavaWithJavac :app:compileDebugJavaWithJavac - is not incremental (e.g. outputs have changed, no previous execution, etc.). :app:compileDebugNdk UP-TO-DATE :app:compileDebugSources :app:buildInfoDebugLoader :app:transformClassesWithExtractJarsForDebug :app:transformClassesWithInstantRunVerifierForDebug :app:transformClassesWithJavaResourcesVerifierForDebug UP-TO-DATE :app:mergeDebugJniLibFolders :app:transformNative_libsWithMergeJniLibsForDebug :app:processDebugJavaRes UP-TO-DATE :app:transformResourcesWithMergeJavaResForDebug :app:transformResourcesAndNative_libsWithJavaResourcesVerifierForDebug UP-TO-DATE :app:transformClassesWithInstantRunForDebug :app:transformClasses_enhancedWithInstant+reloadDexForDebug UP-TO-DATE :app:incrementalDebugTasks :app:prePackageMarkerForDebug :app:fastDeployDebugExtractor :app:generateDebugInstantRunAppInfo :app:coldswapKickerDebug :app:transformClassesWithInstantRunSlicerForDebug :app:transformClassesWithDexForDebug To run dex in process, the Gradle daemon needs a larger heap. It currently has approximately 910 MB. For faster builds, increase the maximum heap size for the Gradle daemon to more than 2048 MB. To do this set org.gradle.jvmargs=-Xmx2048M in the project gradle.properties. For more information see https://docs.gradle.org/current/userguide/build_environment.html Error:java.lang.UnsupportedClassVersionError: com/android/dx/command/Main : Unsupported major.minor version 52.0 Error:java.lang.UnsupportedClassVersionError: com/android/dx/command/Main : Unsupported major.minor version 52.0 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.defineClass1(Native Method) Error: at java.lang.ClassLoader.defineClass(ClassLoader.java:800) Error: at java.lang.ClassLoader.defineClass1(Native Method) Error: at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142) 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.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.lang.ClassLoader.loadClass(ClassLoader.java:358) Error: at java.net.URLClassLoader$1.run(URLClassLoader.java:361) Error: at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142) Error: at java.net.URLClassLoader$1.run(URLClassLoader.java:355) Error: at sun.launcher.LauncherHelper.checkAndLoadMain(LauncherHelper.java:482) Error: at java.security.AccessController.doPrivileged(Native Method) Error: at java.net.URLClassLoader.defineClass(URLClassLoader.java:449) Error: at java.net.URLClassLoader.findClass(URLClassLoader.java:354) Error:Exception in thread "main" Error: at java.lang.ClassLoader.loadClass(ClassLoader.java:425) Error: at java.net.URLClassLoader.access$100(URLClassLoader.java:71) Error: at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308) Error:java.lang.UnsupportedClassVersionError: com/android/dx/command/Main : Unsupported major.minor version 52.0 Error: at java.net.URLClassLoader$1.run(URLClassLoader.java:361) Error: at java.lang.ClassLoader.defineClass1(Native Method) Error: at java.lang.ClassLoader.loadClass(ClassLoader.java:358) :app:transformClassesWithDexForDebug FAILED Error: at java.lang.ClassLoader.defineClass(ClassLoader.java:800) Error: at java.net.URLClassLoader$1.run(URLClassLoader.java:355) Error: at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142) Error: at sun.launcher.LauncherHelper.checkAndLoadMain(LauncherHelper.java:482) Error: at java.net.URLClassLoader.defineClass(URLClassLoader.java:449) 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:Exception in thread "main" 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.net.URLClassLoader.findClass(URLClassLoader.java:354) Error: at java.lang.ClassLoader.loadClass(ClassLoader.java:358) Error: at sun.launcher.LauncherHelper.checkAndLoadMain(LauncherHelper.java:482) Error:Exception in thread "main" 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: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_80\bin\java.exe'' finished with non-zero exit value 1 Information:BUILD FAILED Information:Total time: 7.643 secs Information:61 errors Information:0 warnings Information:See complete output in console



这是我的 build.gradle 文件:
// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.1.2'

// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
} }

allprojects {
repositories {
jcenter()
} }

task clean(type: Delete) {
delete rootProject.buildDir }

我试图清理重建项目,但没有成功。
感谢您的帮助,在此先感谢您。

最佳答案

看一下异常堆栈跟踪,它说失败是由以下原因引起的:

Unsupported major.minor version 52.0



这通常意味着,您正在尝试使用某些类,这些类是使用较新的JDK版本编译的,然后是当前使用的类。在您的情况下,您可以使用JDK 1.8进行编译,但是您正在尝试将其与JDK 1.7一起使用。您可以将JDK更新到1.8,然后再尝试一次。否则,您必须找出导致此失败的原因,然后尝试使用此依赖关系的旧版本。您可以在此 SO question上找到更多内容

关于android - Gradle构建错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37919289/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com