错误 Gradle Build C:\Program Files\Java\jdk1.7.0_79\bin\java.exe'' 以非零退出值 1 结束

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/34766206/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-11 15:57:42  来源:igfitidea点击:

Error Gradle Build C:\Program Files\Java\jdk1.7.0_79\bin\java.exe'' finished with non-zero exit value 1

javaandroid

提问by Arthur Rodrigues

Error:Execution failed for task ':app:transformClassesWithDexForDebug'. com.android.build.api.transform.TransformException: com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command 'C:\Program Files\Java\jdk1.7.0_79\bin\java.exe'' finished with non-zero exit value 1

错误:任务“:app:transformClassesWithDexForDebug”的执行失败。com.android.build.api.transform.TransformException: com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command 'C:\Program Files\Java\jdk1.7.0_79 \bin\java.exe'' 以非零退出值 1 结束

Here is my gradle build file:

这是我的 gradle 构建文件:

apply plugin: 'com.android.application'

android {
    compileSdkVersion 23
    buildToolsVersion "22.0.1"

    defaultConfig {
        applicationId "br.com.gerenciarsc.nfce"
        minSdkVersion 12
        targetSdkVersion 23
        versionCode 1
        versionName "1.0"
        multiDexEnabled true
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile('org.simpleframework:simple-xml:2.7.1') {
        exclude group: 'xpp3', module: 'xpp3'
        exclude group: 'stax', module: 'stax-api'
        exclude group: 'stax', module: 'stax'
    }
    compile 'com.google.code.gson:gson:2.5'
    compile 'com.android.support:appcompat-v7:23.1.1'
    compile 'com.j256.ormlite:ormlite-core:4.48'
    compile 'com.j256.ormlite:ormlite-android:4.48'
    compile 'com.beardedhen:androidbootstrap:2.0.0'
    compile 'com.android.support:multidex:1.0.1'
    compile 'com.android.support:design:23.1.1'
    compile 'com.journeyapps:zxing-android-embedded:3.0.2@aar'
    compile 'com.google.zxing:core:3.2.0'
    compile 'br.com.uol.ps:library:0.8'
    compile 'com.android.support:support-v4:23.1.1'
    compile 'javax.xml.crypto:jsr105-api:1.0.1'
    compile ('commons-io:commons-io:2.4'){
        exclude group: 'org.apache.commons.collections', module: 'org.apache.commons.collections'
    }    
}

回答by Davideas

Found cause and solution.

找到原因和解决办法。

All at the sudden this happened, when I created a class with the same signature (package and name) in 2 different projects of my environment and started the App to try it. Got that message.

突然之间发生了这种情况,当我在我的环境的 2 个不同项目中创建了一个具有相同签名(包和名称)的类并启动应用程序进行尝试时。收到那条消息。

I discovered it by adding multiDexEnabled trueand new error message appeared with duplicated class found.

我通过添加multiDexEnabled true和发现重复的类出现新的错误消息来发现它。

So, I refactored the class (changed package name), also removed multiDexEnabledsupport as it was before, the App started.

因此,我重构了类(更改了包名称),也删除了multiDexEnabled之前的支持,应用程序启动。

回答by Dhananjay M

I faced the same issue. Scrolling down, I found the following error in the logs:

我遇到了同样的问题。向下滚动,我在日志中发现以下错误:

java.lang.UnsupportedClassVersionError: com/android/dx/command/Main : Unsupported major.minor version 52.0

java.lang.UnsupportedClassVersionError: com/android/dx/command/Main : 不支持major.minor 版本52.0

Then I searched for the above error and found the following work-around as suggested by the solutions to this questionand another similar question:

然后我搜索了上述错误,并按照此问题和另一个类似问题的解决方案的建议找到了以下解决方法:

In the file build.gradle(Module:app) I changed the following from:

在文件 build.gradle(Module:app) 中,我更改了以下内容:

buildToolsVersion "24.0.0"

buildToolsVersion "24.0.0"

to

buildToolsVersion "23.0.2"

buildToolsVersion "23.0.2"

and clicked the button to "sync project with gradle files" in Android Studio and the error vanished.

并单击按钮以在 Android Studio 中“将项目与 gradle 文件同步”,错误消失了。

Note: I didn't understand the exact reason for the error and it's solution completely but it seems to be a compatibility issue of java version 1.7 and Android API level 24. Some people suggested (on the questions' links I mentioned) to use JDK version 8 with API 24, or downgrade it to JDK version 7 and API level 23.0.x as a work around.

注意:我不明白错误的确切原因,它完全是解决方案,但它似乎是 java 1.7 版和 Android API 级别 24 的兼容性问题。有些人建议(在我提到的问题的链接上)使用 JDK使用 API 24 的版本 8,或将其降级到 JDK 版本 7 和 API 级别 23.0.x 作为变通方法。

回答by faisal

In my case, I changed buildToolVersion in build.gradle(module:app) to 23.0.2 then the app is running.

就我而言,我将 build.gradle(module:app) 中的 buildToolVersion 更改为 23.0.2,然后应用程序正在运行。

回答by Raja

I also faced the same issue after did reach i got resolved. issue could be the classes folder not created under build directory while you build the project, the reason for that the project path may not correct. so you have to correct the project path and rebuild that it will work fine. java files should be under path \src\main\java for gradle proejct

在达到我得到解决后,我也遇到了同样的问题。问题可能是在构建项目时未在构建目录下创建类文件夹,原因是项目路径可能不正确。所以你必须更正项目路径并重建它才能正常工作。对于 gradle proejct,java 文件应该在路径 \src\main\java 下

回答by maja89

I've got this error:

我有这个错误:

Execution failed for task ':vvm:transformClassesWithDesugarForRelease'. com.android.build.api.transform.TransformException: org.gradle.process.internal.ExecException: A problem occurred starting process 'command 'E:\Java\jdk1.8.0_181\bin\java.exe''

任务“:vvm:transformClassesWithDesugarForRelease”执行失败。com.android.build.api.transform.TransformException: org.gradle.process.internal.ExecException: 启动进程时出现问题 'command 'E:\Java\jdk1.8.0_181\bin\java.exe''

I've solved it by updating gradle from 4.4 to 5.4

我已经通过将 gradle 从 4.4 更新到 5.4 解决了这个问题

回答by Ashish Katiyar

I also faced the same issue after did reach i not resolved. instead of applied two approaches as follows:

在达到我没有解决之后,我也遇到了同样的问题。而不是应用以下两种方法:

Process 1: Update plugin with build.gradle

流程 1:使用 build.gradle 更新插件

plugins {
id "com.github.ManifestClasspath" version "0.1.0-RELEASE"
}

Process 2: Update the JAVA path while executing the application inside the IDE

流程二:在IDE内执行应用程序时更新JAVA路径

Still it is not working.

它仍然不起作用。