我添加了recyclerview gradle build,然后尝试运行该应用程序,现在我收到此错误:
错误:任务':app:dexDebug'执行失败。
com.android.ide.common.process.ProcessException:org.gradle.process.internal.ExecException:进程'命令' C:\ Program Files \ Java \ jdk1.7.0_79 \ bin \的java.exe''完成非零退出值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')
}
如何解决这个问题?
答案 0 :(得分:8)
It looks like you have reached the dex limit and you have over 65k methods in your application.
If you want to keep all of your gradle dependencies as is, you should look into configuring multidex that way it will build your application using multiple dex files.
Another solution would be to try and remove any unnecessary dependencies from the google play services library. Chances are you don't need to include everything and you can choose to add only the imports you need.
For example:
com.google.android.gms:play-services-maps:7.5.0
com.google.android.gms:play-services-gcm:7.5.0
Rather than simply using:
compile 'com.google.android.gms:play-services:7.5.0'
You can reference the Google Play Services guide to determine which pieces of library you should add.
答案 1 :(得分:1)
Android Studio建议,
避免在版本号中使用+会导致不可预测和不可重复的构建。
依赖项中的+允许您自动获取最新的可用版本而不是特定版本,但不建议这样做。
您可能使用与使用的构建服务器略有不同的版本进行了测试。
删除加号和添加特定版本问题解决后。