Gradle 构建失败 - Java.exe 以非零退出值 2 完成
Gradle Build failed - Java.exe is finished with non-zero exit value 2
我已经添加了 recyclerview gradle 构建然后尝试 运行 应用程序,现在我得到这个错误:
错误:任务“:app:dexDebug”执行失败。
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 2
这是我的 gradle 构建文件:
dependencies {
compile 'com.android.support:appcompat-v7:22.1.1'
compile 'com.android.support:recyclerview-v7:22.1.1'
compile fileTree(dir: 'libs', include: 'Parse-*.jar')
compile 'com.parse.bolts:bolts-android:1.2.0'
compile 'com.android.support:design:22.2.0'
compile 'com.google.android.gms:play-services:7.5.0'
compile 'com.facebook.fresco:fresco:0.5.2+'
compile 'com.facebook.android:facebook-android-sdk:4.1.0'
compile fileTree(dir: 'libs', include: 'commons-io-*.jar')
compile fileTree(dir: 'libs', include: 'ParseFacebookUtilsV4-*.jar')
}
如何解决这个问题?
您似乎已达到 dex 限制并且您的应用程序中有超过 65k 个方法。
如果您想保持所有 gradle 依赖项不变,您应该查看 configuring multidex ,这样它会使用多个 dex 文件构建您的应用程序。
另一种解决方案是尝试从 google 播放服务库中删除任何不必要的依赖项。您可能不需要包含所有内容,您可以选择只添加您需要的导入。
例如:
com.google.android.gms:play-services-maps:7.5.0
com.google.android.gms:play-services-gcm:7.5.0
而不是简单地使用:
compile 'com.google.android.gms:play-services:7.5.0'
您可以参考 Google Play Services guide 来确定您应该添加哪些库。
Android工作室建议,
Avoid using + in version numbers can lead to unpredictable and unrepeatable builds.
+ in dependencies lets you pick up automatically the latest available version rather than a specific one, however this is not recommended.
You may have tested with a slightly different version than what build server used.
在删除加号和添加特定版本后问题已解决。
我已经添加了 recyclerview gradle 构建然后尝试 运行 应用程序,现在我得到这个错误:
错误:任务“:app:dexDebug”执行失败。
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 2
这是我的 gradle 构建文件:
dependencies {
compile 'com.android.support:appcompat-v7:22.1.1'
compile 'com.android.support:recyclerview-v7:22.1.1'
compile fileTree(dir: 'libs', include: 'Parse-*.jar')
compile 'com.parse.bolts:bolts-android:1.2.0'
compile 'com.android.support:design:22.2.0'
compile 'com.google.android.gms:play-services:7.5.0'
compile 'com.facebook.fresco:fresco:0.5.2+'
compile 'com.facebook.android:facebook-android-sdk:4.1.0'
compile fileTree(dir: 'libs', include: 'commons-io-*.jar')
compile fileTree(dir: 'libs', include: 'ParseFacebookUtilsV4-*.jar')
}
如何解决这个问题?
您似乎已达到 dex 限制并且您的应用程序中有超过 65k 个方法。
如果您想保持所有 gradle 依赖项不变,您应该查看 configuring multidex ,这样它会使用多个 dex 文件构建您的应用程序。
另一种解决方案是尝试从 google 播放服务库中删除任何不必要的依赖项。您可能不需要包含所有内容,您可以选择只添加您需要的导入。
例如:
com.google.android.gms:play-services-maps:7.5.0
com.google.android.gms:play-services-gcm:7.5.0
而不是简单地使用:
compile 'com.google.android.gms:play-services:7.5.0'
您可以参考 Google Play Services guide 来确定您应该添加哪些库。
Android工作室建议,
Avoid using + in version numbers can lead to unpredictable and unrepeatable builds.
+ in dependencies lets you pick up automatically the latest available version rather than a specific one, however this is not recommended.
You may have tested with a slightly different version than what build server used.
在删除加号和添加特定版本后问题已解决。