当我运行我的应用程序时,我得到了错误com.android.dex.DexException: Multiple dex files define Lcom/google/android/gms/internal/zzau;
。
app.gradle
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
compile 'com.android.support:support-v4:21.0.3'
compile 'com.android.support:appcompat-v7:21.0.3'
compile 'com.android.support:recyclerview-v7:21.0.0'
compile 'com.android.support:cardview-v7:21.0.0'
compile 'com.google.android.gms:play-services:7.0.+'
compile 'com.android.support:mediarouter-v7:21.0.3'
compile 'com.squareup:otto:1.3.5'
compile 'com.squareup.picasso:picasso:2.3.4'
compile 'com.squareup.okhttp:okhttp:2.2.0'
compile 'com.squareup.okhttp:okhttp-urlconnection:2.2.0'
compile 'com.squareup.retrofit:retrofit:1.9.0'
compile 'com.github.ksoichiro:android-observablescrollview:1.4.0'
compile 'com.astuetz:pagerslidingtabstrip:1.0.1'
compile 'com.facebook.android:facebook-android-sdk:4.1.0'
compile 'com.parse.bolts:bolts-android:1.+'
compile 'com.edmodo:rangebar:1.0.0'
compile 'com.melnykov:floatingactionbutton:1.3.0'
compile project(':library_viewpager')
compile project(':androidHorizontalListView')
compile project(':CastCompanionLibrary')
compile project(':mobihelp_sdk_android_v1.4')
compile fileTree(include: 'Parse-*.jar', dir: 'libs')
compile files('libs/Parse-1.9.2.jar')
compile files('libs/GoogleConversionTrackingSdk-2.2.2.jar')
}
CastCompanionLibrary
dependencies {
compile 'com.android.support:appcompat-v7:22.+'
compile 'com.android.support:mediarouter-v7:22.+'
compile 'com.google.android.gms:play-services-cast:7.5.0'
}
我该如何解决这个问题?我猜这个错误是因为我在模块和应用程序中都使用了google play服务。但是版本是不同的。这会引起问题吗?
发布于 2015-07-16 17:11:17
我也有类似的问题,你的问题帮助我解决了我的问题,可能也会帮助你解决你的问题。问题是你已经定义了:
dependencies {
...
compile 'com.google.android.gms:play-services-cast:7.5.0'
}
和
dependencies {
...
compile 'com.google.android.gms:play-services:7.0.+'
...
}
从google services 7.5.0开始,如果你使用play服务中的单个模块,你就不能同时使用整个play服务作为依赖项。解决方案是只选择您需要的那些服务,而不是整个包,例如:
而不是
dependencies {
...
compile 'com.google.android.gms:play-services:7.0.+'
...
}
使用
dependencies {
...
compile 'com.google.android.gms:play-services-maps:7.0.+'
compile 'com.google.android.gms:play-services-location:7.0.+'
compile 'com.google.android.gms:play-services-gcm:7.0.+'
...
}
我也不确定,但在两个gradle配置中使用相同版本的google服务可能是个好主意。
发布于 2016-07-28 13:07:07
在使用phonegap/cordova进行构建后,我遇到了类似的问题: com.android.dex.DexException:多个dex文件定义了Lcom/google/android/gms/internal/zzsk;
我通过编辑build.gradle(模块安卓)修复了它,因为我有两个库,它们应该有完全相同的版本,但版本号不同(在我的例子中是8.4.0和9.2.1 )
dependencies{
....
//make sure are both same version (8.4.0 or 9.2.1 in my case)
compile 'com.google.android.gms:play-services-gcm:9.2.1'
// this is the one I changed: compile 'com.google.android.gms:play-services-location:8.4.0'
compile 'com.google.android.gms:play-services-location:9.2.1' // it was 8.4.0
....
}
发布于 2018-03-14 04:47:16
如果这种情况发生在react-native-device-info上,则只能从以下位置更改:
compile(project(':react-native-device-info'))
至
compile(project(':react-native-device-info')) {
exclude group: 'com.google.android.gms'
}
https://stackoverflow.com/questions/31224276
复制相似问题