Java :app:dexDebug ExecException 以非零退出值 2 结束

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/30001051/
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 08:57:04  来源:igfitidea点击:

:app:dexDebug ExecException finished with non-zero exit value 2

javaandroidandroid-studiogradleandroid-gradle-plugin

提问by Prajun Adhikary

Could anyone help me out with the following error. When i clean the project, it doesn't show any error but every time i try to run i get this message.

任何人都可以帮助我解决以下错误。当我清理项目时,它没有显示任何错误,但每次我尝试运行时都会收到此消息。

Error:Execution failed for task ':app:dexDebug'.

错误:任务 ':app:dexDebug' 执行失败。

com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command 'C:\Program Files\Java\jdk1.8.0_45\bin\java.exe'' finished with non-zero exit value 2

com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command 'C:\Program Files\Java\jdk1.8.0_45\bin\java.exe'' 完成了非零退出值 2

The application was running with no errors but as my system crashed and restarted android studio i had few updates for Android API 22. After the update the application keep giving me this error message. I downloaded JDK 8 and tried to run but didn't work. Later i downgraded to JDK 7 after this stack post but still has not fixed it. Is it possible to use Java 8 for Android development?

该应用程序运行时没有错误,但是当我的系统崩溃并重新启动 android studio 时,我几乎没有对 Android API 22 进行更新。更新后,应用程序不断给我这个错误消息。我下载了 JDK 8 并尝试运行但没有工作。后来我在这个堆栈帖子之后降级到 JDK 7,但仍然没有修复它。 是否可以将 Java 8 用于 Android 开发?

I have looked through numerous similar question but none works for me. Some similar issues found on stack were

我已经浏览了许多类似的问题,但没有一个对我有用。在堆栈上发现的一些类似问题是

why java.exe exit with value 1 in android studio

为什么java.exe在android studio中以值1退出

Error:Execution failed for task ':app:dexDebug'. > comcommand finished with non-zero exit value 2

错误:任务 ':app:dexDebug' 执行失败。> comcommand 以非零退出值 2 结束

Java finished with non-zero exit value 2 - Android Gradle

Java 以非零退出值 2 结束 - Android Gradle

java.exe finished with non-zero exit value 2

java.exe 以非零退出值 2 结束

Process 'command' C: \ Program Files \ Java \ jdk1.8.0_31 \ bin \ java.exe '' finished with a non -zero exit value 2

Process 'command' C:\Program Files\Java\jdk1.8.0_31\bin\java.exe''以非零退出值2结束

I have looked through dependencies in gradle built to see if there were any conflict but found none.

我查看了 gradle 中的依赖项,看看是否有任何冲突,但没有发现。

I even tried to copy the code into a new project and run it but still no success. Anyone who has faced the same issue and solved it please help me out.

我什至试图将代码复制到一个新项目中并运行它,但仍然没有成功。任何遇到同样问题并解决了它的人请帮助我。

采纳答案by Prajun Adhikary

After days of trying out finally could fix the issue. The problem with one of my .jar files. I had to remove each jar and check one by one until i found it. I removed the .jar file and cleaned my project and ran successfully. If any one should face similar issue check your jar file one by one.

经过几天的尝试,终于可以解决这个问题。我的 .jar 文件之一的问题。我不得不取出每个罐子并一一检查,直到找到为止。我删除了 .jar 文件并清理了我的项目并成功运行。如果有人遇到类似问题,请一一检查您的 jar 文件。

回答by ljuarezengineer

I was using the robolectric dependency in my android project. I removed all robolectric dependencies in gradle and deleted all my robolectric tests, then I built the app and finally I could run the android project. Hope this can work for us.

我在我的 android 项目中使用了 robolectric 依赖项。我删除了 gradle 中的所有 robolectric 依赖项并删除了我所有的 robolectric 测试,然后我构建了应用程序,最后我可以运行 android 项目。希望这对我们有用。

回答by joshgoldeneagle

For me the solution was to remove an unnecessary/duplicate dependency entries. This is a similar solution others offered here that makes sense, but not exactly the same solution as those offered by others.

对我来说,解决方案是删除不必要/重复的依赖项。这是其他人在这里提供的类似解决方案,但与其他人提供的解决方案并不完全相同。

Since I was already including *.jar files in the list of files to be compiled, there was no need for additional entries in the dependencies list.

由于我已经在要编译的文件列表中包含了 *.jar 文件,因此不需要在依赖项列表中添加其他条目。



Before:



前:

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])

    compile 'com.android.support:appcompat-v7:22.2.0'
    compile 'com.parse.bolts:bolts-android:1.+'
    compile fileTree(dir: 'libs', include: 'Parse-*.jar')
}

After:

后:

dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])

compile 'com.android.support:appcompat-v7:22.2.0'

}

}

回答by Matt Edwards

For future readers. If you're using your own AARs and upgraded one that has a shared dependency, you can also just try cleaning the project. In Android Studio "Build" -> "Clean Project".

对于未来的读者。如果您使用自己的 AAR 并升级了具有共享依赖项的 AAR,您也可以尝试清理项目。在 Android Studio 中“构建”->“清理项目”。

This solved the issue for me, so I'd recommend giving it a quick try before you start digging for dependencies.

这为我解决了这个问题,因此我建议您在开始挖掘依赖项之前快速尝试一下。

回答by Netero

I had the same error

我有同样的错误

app:dexDebug ExecException finished with non-zero exit value 2

app:dexDebug ExecException 以非零退出值 2 结束

i solve it by adding this line of code

我通过添加这行代码来解决它

defaultConfig {
        multiDexEnabled true
}

The reason is that i was using too many libraries

原因是我使用了太多的库

Hope this post will help anyone

希望这篇文章可以帮助任何人

回答by Arthy Shankari M

I had the same problem when I compiled google play services to my dependencies.

当我将 google play 服务编译到我的依赖项时,我遇到了同样的问题。

My mistake was I was compiling the enitre package like this

我的错误是我正在编译这样的 enitre 包

compile 'com.google.android.gms:play-services:8.3.0'

编译 'com.google.android.gms:play-services:8.3.0'

Instead when I tried the selective compile, it worked.In my case I was using for google sign in,so it had just had to be

相反,当我尝试选择性编译时,它起作用了。在我的情况下,我使用的是谷歌登录,所以它只需要

compile 'com.google.android.gms:play-services-auth:8.3.0'.

编译“com.google.android.gms:play-services-auth:8.3.0”。

More details are in the documentaion. https://developers.google.com/android/guides/setup#split

更多细节在文档中。https://developers.google.com/android/guides/setup#split

Hope this will be of a little help to someone someday :)

希望有一天这对某人有一点帮助:)

回答by Neria Nachum

I faced the same problem when trying to add the SignalR Java clientlibrary to my project's dependencies. I first changed the target JDK of my app from 1.8.0_XX to 1.7.0_XX, but it didn't work. Then I changed the SignalR project to target 1.7.0_XX as well, rebuilt and added it to my project's libs folder instead of the first build (which was in 1.8.0_XX), and that miraculously worked.

尝试将SignalR Java 客户端库添加到我的项目依赖项时,我遇到了同样的问题。我首先将我的应用程序的目标 JDK 从 1.8.0_XX 更改为 1.7.0_XX,但它不起作用。然后我将 SignalR 项目也更改为目标 1.7.0_XX,重建并将其添加到我的项目的 libs 文件夹而不是第一个构建(在 1.8.0_XX 中),并且奇迹般地起作用了。

回答by Keyul

Remove compile 'com.parse:parse-android:1.+'

消除 compile 'com.parse:parse-android:1.+'

add this linecompile fileTree(dir: 'libs', include: ['Parse-*.jar'])

添加这一行compile fileTree(dir: 'libs', include: ['Parse-*.jar'])

Finally, it will look like this

最后,它看起来像这样

dependencies {
compile fileTree(dir: 'libs', include: ['Parse-*.jar'])
compile 'com.android.support:appcompat-v7:22.2.0'
compile 'com.facebook.android:facebook-android-sdk:4.5.0'
compile 'com.android.support:design:22.2.0'
compile 'com.parse.bolts:bolts-android:1.+'
}

回答by shahrukhamd

For me, the problem was that I was using different versions of "Google Play services sub API's"

对我来说,问题是我使用了不同版本的“Google Play 服务子 API”

Before:Click to see the image

之前:点击查看图片

After:Click to see the image

之后:点击查看图片

回答by Eder Ramírez Hernández

I had the same problem, just i did Biuld--> Rebiuld project and it works again ;)

我遇到了同样的问题,只是我做了 Biuld--> Rebiuld 项目,它又可以工作了 ;)