多个dex文件定义Lcom/google/android/gms/internal/zzau

Tch*_*mai 40 android google-play-services

com.android.dex.DexException: Multiple dex files define Lcom/google/android/gms/internal/zzau;运行我的应用程序时收到错误gradle文件是

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')
}
Run Code Online (Sandbox Code Playgroud)

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'
}
Run Code Online (Sandbox Code Playgroud)

我该如何解决?我想错误的发生是因为我在模块和应用程序中都使用谷歌播放服务.但版本不同.是造成问题的?

小智 30

我有类似的问题,你的问题帮助我解决了我的问题,可能会帮助你解决问题.问题是你已定义:

dependencies {
...
  compile 'com.google.android.gms:play-services-cast:7.5.0'
}
Run Code Online (Sandbox Code Playgroud)

dependencies {
...
  compile 'com.google.android.gms:play-services:7.0.+'
...
}
Run Code Online (Sandbox Code Playgroud)

自谷歌服务7.5.0以来,如果您使用播放服务中的单个模块,则无法同时使用整个播放服务作为依赖项.解决方案是仅选择您需要的服务而不是整个包,例如:

代替

dependencies {
...
  compile 'com.google.android.gms:play-services:7.0.+'
...
}
Run Code Online (Sandbox Code Playgroud)

使用

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.+'
...
}
Run Code Online (Sandbox Code Playgroud)

此外,我不确定,但在两个gradle配置中使用相同版本的谷歌服务可能是个好主意.

  • 问题也可能出现在"com.google.android.gms"和"com.google.firebase"的不同版本中 (5认同)

raf*_*oro 16

使用phonegap/cordova构建后我遇到了类似的问题:com.android.dex.DexException:多个dex文件定义了Lcom/google/android/gms/internal/zzsk;

我通过编辑build.gradle(模块Android)来修复它,因为我有2个库应该具有完全相同的版本和不同的版本号(在我的情况下为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
....
}
Run Code Online (Sandbox Code Playgroud)


小智 5

Firebase Android SDK现在具有独立的版本号,允许更频繁,更灵活的更新.

将所有Firebase依赖项更新为最新版本(截至2018年5月2日):

 Firebase Core          com.google.firebase:firebase-core:15.0.2
    Ads                 com.google.firebase:firebase-ads:15.0.0
  Analytics             com.google.firebase:firebase-analytics:15.0.2
 App Indexing           com.google.firebase:firebase-appindexing:15.0.0
 Authentication         com.google.firebase:firebase-auth:15.1.0
Cloud Firestore         com.google.firebase:firebase-firestore:16.0.0
Cloud Functions         com.google.firebase:firebase-functions:15.0.0
Cloud Messaging         com.google.firebase:firebase-messaging:15.0.2
Cloud Storage           com.google.firebase:firebase-storage:15.0.2
Crash Reporting         com.google.firebase:firebase-crash:15.0.2
Crashlytics             com.crashlytics.sdk.android:crashlytics:2.9.1
Invites                 com.google.firebase:firebase-invites:15.0.2
Performance Monitoring  com.google.firebase:firebase-perf:15.1.0
Realtime Database       com.google.firebase:firebase-database:15.0.0
Remote Config           com.google.firebase:firebase-config:15.0.2
Run Code Online (Sandbox Code Playgroud)

发行说明:https://firebase.google.com/support/release-notes/android