我添加了 recyclerview gradle build 然后尝试运行该应用程序,现在我收到此错误:
错误:任务 ':app:dexDebug' 执行失败。
这是我的 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 play 服务库中删除任何不必要的依赖项。您可能不需要包含所有内容,您可以选择仅添加您需要的导入。
例如:
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 来确定您应该添加哪些库。