I added leaderboards to my android game using google games api. Now I wanted to add banner ads using the Firebase 'Wizard' of Android Studio. It builds fine, but when I try to create an apk, I get the following error:
Error:Error converting bytecode to dex: Cause: com.android.dex.DexException: Multiple dex files define Lcom/google/android/gms/internal/zzqv;
After using the wizard, my build.gradle file looks like this:
apply plugin: 'com.android.application'
android {
compileSdkVersion 22
buildToolsVersion "22.0.1"
defaultConfig {
applicationId "xxx"
minSdkVersion 15
targetSdkVersion 22
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'),'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile project(':BaseGameUtils')
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile 'com.google.android.gms:play-services-games:10.0.1'
compile 'com.google.firebase:firebase-ads:10.0.1'
testCompile 'junit:junit:4.12'
}
apply plugin: 'com.google.gms.google-services'
I tried/read all things related to the multiple dex files problem, but nothing worked for me. Anyone has a hint for me? Do I have to use Firebase for leaderboards as well? Couldn't find how...
Thanks for any help/hints pettersson
thanks to Clayton Wilkinson's comment, I could fix my problem. The problem was that BaseGameUtils was still using/referencing an older version of play-services. Added the correct version, and it works now. Guess I will omit BaseGameUtils for my next project.
Thanks a lot
Sure, there are some conflicts... But, the thing is that if you talk in general terms, I mean, you use compile 'com.google.android.gms:play-services:X.X.X', it's done.
I had the same error, just enabling proguard worked (change false to true) :
buildTypes {
release {
minifyEnabled true //Here change false to true
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt')
}
}
来源:https://stackoverflow.com/questions/41491074/mixing-google-play-games-with-firebase