Build errors after updating Gradle dependencies. Suspect #1 is firebase











up vote
1
down vote

favorite












I have an app that builds just fine, but starts failing as soon as I try to update some Gradle dependencies, whereas the main suspect is firebase.



This is the error I'm getting:




Caused by:
com.android.builder.multidex.D8MainDexList$MainDexListException:
com.android.tools.r8.errors.CompilationError: Program type already
present: com.google.android.gms.internal.measurement.zzdz




And this is the git diff for my project, showing the differences in the Gradle files:



diff --git a/android/build.gradle b/android/build.gradle
index 9f63f745..08fda2eb 100644
--- a/android/build.gradle
+++ b/android/build.gradle
@@ -81,8 +81,8 @@ dependencies {
implementation "com.badlogicgames.gdx:gdx-backend-android:$gdxVersion"
implementation "com.badlogicgames.gdx:gdx-freetype:$gdxVersion"
implementation "com.android.billingclient:billing:$playBillingLibVersion"
- implementation "com.google.firebase:firebase-core:16.0.3"
- implementation "com.google.firebase:firebase-ads:15.0.1"
+ implementation "com.google.firebase:firebase-core:16.0.5"
+ implementation "com.google.firebase:firebase-ads:17.0.0"
implementation 'com.crashlytics.sdk.android:crashlytics:2.9.5'

implementation fileTree(include: ['*.jar'], dir: 'libs')
diff --git a/android_common/build.gradle b/android_common/build.gradle
index f8224509..3a5d45e1 100644
--- a/android_common/build.gradle
+++ b/android_common/build.gradle
@@ -19,7 +19,7 @@ android {
androidTest.setRoot('tests')
}
defaultConfig {
- minSdkVersion 15
+ minSdkVersion 16
targetSdkVersion 28
versionCode 1
versionName "1.0"
@@ -65,8 +65,8 @@ dependencies {
natives "com.badlogicgames.gdx:gdx-freetype-platform:$gdxVersion:natives-x86"
natives "com.badlogicgames.gdx:gdx-freetype-platform:$gdxVersion:natives-x86_64"
implementation "com.android.billingclient:billing:$playBillingLibVersion"
- implementation "com.google.firebase:firebase-core:16.0.3"
- implementation "com.google.firebase:firebase-ads:15.0.1"
+ implementation "com.google.firebase:firebase-core:16.0.5"
+ implementation "com.google.firebase:firebase-ads:17.0.0"

implementation fileTree(include: ['*.jar'], dir: 'libs')
testImplementation 'junit:junit:4.12'
diff --git a/android_instant_feature/build.gradle b/android_instant_feature/build.gradle
index 30431c11..17c4ef27 100644
--- a/android_instant_feature/build.gradle
+++ b/android_instant_feature/build.gradle
@@ -18,7 +18,7 @@ android {
defaultConfig {
versionCode 4031
versionName "4.1.2.1i"
- minSdkVersion 15
+ minSdkVersion 16
targetSdkVersion 28
multiDexEnabled true
}
@@ -77,8 +77,8 @@ dependencies {
api 'com.android.support:multidex:1.0.3'
implementation "com.badlogicgames.gdx:gdx-backend-android:$gdxVersion"
implementation "com.badlogicgames.gdx:gdx-freetype:$gdxVersion"
- implementation "com.google.firebase:firebase-core:16.0.3"
- implementation 'com.google.android.gms:play-services-instantapps:16.0.0'
+ implementation "com.google.firebase:firebase-core:16.0.5"
+ implementation 'com.google.android.gms:play-services-instantapps:16.0.1'

implementation fileTree(dir: 'libs', include: ['*.jar'])
}
diff --git a/core/build.gradle b/core/build.gradle
index dd2640cf..5694a1da 100644
--- a/core/build.gradle
+++ b/core/build.gradle
@@ -15,7 +15,7 @@ dependencies {
compile group: 'commons-io', name: 'commons-io', version: '2.6'
// https://mvnrepository.com/artifact/commons-codec/commons-codec
compile group: 'commons-codec', name: 'commons-codec', version: '1.11'
- compile 'com.google.code.gson:gson:2.8.2'
+ compile 'com.google.code.gson:gson:2.8.5'
compile group: 'org.apache.commons', name: 'commons-text', version: '1.2'
compile group: 'org.apache.commons', name: 'commons-collections4', version: '4.1'
compile group: 'org.jetbrains', name: 'annotations', version: '16.0.1'
@@ -23,7 +23,7 @@ dependencies {
implementation "com.badlogicgames.gdx:gdx-freetype:$gdxVersion"

testCompile 'junit:junit:4.12'
- testCompile 'org.mockito:mockito-core:2.7.22'
+ testCompile 'org.mockito:mockito-core:2.8.9'
testCompile group: 'org.powermock', name: 'powermock-api-mockito2', version: '1.7.3'
testCompile group: 'org.powermock', name: 'powermock-module-junit4', version: '1.7.3'
}


Please, note that some of these changes like the minSDKVersion can be discarded as the source of the error. It seems most likely it is related to firebase. Why? Well, among other things there are other questions in Stackoverflow in which that's the case, however the solution proposed in all of these is to update firebase dependencies to last version, but updating firebase dependencies to last version is what it seems to be causing the problem in my project! With the old versions it just builds fine.



These are the contents of the Gradle scripts involved (I have replaced the actual applicationId with 'com.myapp.id')



:core



apply plugin: "java"

targetCompatibility = 1.8
sourceCompatibility = 1.8
[compileJava, compileTestJava]*.options*.encoding = 'UTF-8'

sourceSets.main.java.srcDirs = ["src/main"]
sourceSets.test.java.srcDirs = ["src/test"]

dependencies {
compile 'commons-io:commons-io:2.6'
compile 'commons-codec:commons-codec:1.11'
compile 'com.google.code.gson:gson:2.8.5'
compile 'org.apache.commons:commons-text:1.2'
compile 'org.apache.commons:commons-collections4:4.1'
compile 'org.jetbrains:annotations:16.0.1'
compile "com.badlogicgames.gdx:gdx:1.9.9-SNAPSHOT"
compile "com.badlogicgames.gdx:gdx-freetype:1.9.9-SNAPSHOT"

testCompile 'junit:junit:4.12'
testCompile 'org.mockito:mockito-core:2.8.9'
testCompile 'org.powermock:powermock-api-mockito2:1.7.3'
testCompile 'org.powermock:powermock-module-junit4:1.7.3'
}


repositories {
mavenCentral()
}

jar {
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
}


:android_common



apply plugin: "com.android.feature"

configurations { natives }

android {
baseFeature true
compileSdkVersion 28
sourceSets {
main {
manifest.srcFile 'AndroidManifest.xml'
java.srcDirs = ['src']
aidl.srcDirs = ['src']
renderscript.srcDirs = ['src']
res.srcDirs = ['res']
assets.srcDirs = ['assets']
jniLibs.srcDirs = ['libs']
}

androidTest.setRoot('tests')
}
defaultConfig {
minSdkVersion 16
targetSdkVersion 28
versionCode 1
versionName "1.0"

testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
sourceSets {
all {
manifest.srcFile "AndroidManifest.xml"
}
}
multiDexEnabled true
}
buildTypes {
release {
setMinifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
buildToolsVersion '28.0.2'
lintOptions {
abortOnError false
}
dexOptions {
jumboMode true
}
}

dependencies {
application project(':android')
feature project(':android_instant_feature')
api project(':core')
api 'com.android.support:multidex:1.0.3'
implementation "com.badlogicgames.gdx:gdx-backend-android:1.9.9-SNAPSHOT"
natives "com.badlogicgames.gdx:gdx-platform:1.9.9-SNAPSHOT:natives-armeabi"
natives "com.badlogicgames.gdx:gdx-platform:1.9.9-SNAPSHOT:natives-armeabi-v7a"
natives "com.badlogicgames.gdx:gdx-platform:1.9.9-SNAPSHOT:natives-arm64-v8a"
natives "com.badlogicgames.gdx:gdx-platform:1.9.9-SNAPSHOT:natives-x86"
natives "com.badlogicgames.gdx:gdx-platform:1.9.9-SNAPSHOT:natives-x86_64"
implementation "com.badlogicgames.gdx:gdx-freetype:1.9.9-SNAPSHOT"
natives "com.badlogicgames.gdx:gdx-freetype-platform:1.9.9-SNAPSHOT:natives-armeabi"
natives "com.badlogicgames.gdx:gdx-freetype-platform:1.9.9-SNAPSHOT:natives-armeabi-v7a"
natives "com.badlogicgames.gdx:gdx-freetype-platform:1.9.9-SNAPSHOT:natives-arm64-v8a"
natives "com.badlogicgames.gdx:gdx-freetype-platform:1.9.9-SNAPSHOT:natives-x86"
natives "com.badlogicgames.gdx:gdx-freetype-platform:1.9.9-SNAPSHOT:natives-x86_64"
implementation "com.android.billingclient:billing:dp-1"
implementation "com.google.firebase:firebase-core:16.0.5"
implementation "com.google.firebase:firebase-ads:17.0.0"

implementation fileTree(include: ['*.jar'], dir: 'libs')
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
implementation 'com.google.guava:guava:24.0-android'
}

task copyAndroidNatives() {
file("libs/armeabi/").mkdirs();
file("libs/armeabi-v7a/").mkdirs();
file("libs/arm64-v8a/").mkdirs();
file("libs/x86_64/").mkdirs();
file("libs/x86/").mkdirs();

configurations.natives.files.each { jar ->
def outputDir = null
if (jar.name.endsWith("natives-arm64-v8a.jar")) outputDir = file("libs/arm64-v8a")
if (jar.name.endsWith("natives-armeabi-v7a.jar")) outputDir = file("libs/armeabi-v7a")
if (jar.name.endsWith("natives-armeabi.jar")) outputDir = file("libs/armeabi")
if (jar.name.endsWith("natives-x86_64.jar")) outputDir = file("libs/x86_64")
if (jar.name.endsWith("natives-x86.jar")) outputDir = file("libs/x86")
if (outputDir != null) {
copy {
from zipTree(jar)
into outputDir
include "*.so"
}
}
}
}


:android



apply plugin: "com.android.application"
apply plugin: 'io.fabric' // Needed by crashlytics. DO NOT REMOVE.

android {
buildToolsVersion "28.0.2"
compileSdkVersion 28
sourceSets {
main {
manifest.srcFile 'AndroidManifest.xml'
java.srcDirs = ['src']
aidl.srcDirs = ['src']
renderscript.srcDirs = ['src']
res.srcDirs = ["${project(':android_common').projectDir}/res"]
assets.srcDirs = ['assets']
jniLibs.srcDirs = ['libs']
}

androidTest.setRoot('tests')
}
defaultConfig {
applicationId "com.myapp.id"
versionCode 4032
versionName "4.1.2.1"
minSdkVersion 16
targetSdkVersion 28
multiDexEnabled true
}
dexOptions {
jumboMode true
}
// Proguard configuration
buildTypes {
release {
//minifyEnabled true will turn proguard ON
minifyEnabled true
//proguardFiles let you add your own proguard rules ('proguard-project.txt') in this case, as its already created by gdx-setup
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-project.txt'
}
}

compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
productFlavors {
}
lintOptions {
abortOnError false
}
}

task importPuzzles(type: Exec) {
// TODO
}

task run(type: Exec) {
def path
def localProperties = project.file("../local.properties")
if (localProperties.exists()) {
Properties properties = new Properties()
localProperties.withInputStream { instr ->
properties.load(instr)
}
def sdkDir = properties.getProperty('sdk.dir')
if (sdkDir) {
path = sdkDir
} else {
path = "$System.env.ANDROID_HOME"
}
} else {
path = "$System.env.ANDROID_HOME"
}

def adb = path + "/platform-tools/adb"
commandLine "$adb", 'shell', 'am', 'start', '-n', 'com.myapp.id/com.myapp.id.AndroidLauncher'
}

dependencies {
implementation project(":android_common")
api 'com.android.support:multidex:1.0.3'
implementation "com.badlogicgames.gdx:gdx-backend-android:1.9.9-SNAPSHOT"
implementation "com.badlogicgames.gdx:gdx-freetype:1.9.9-SNAPSHOT"
implementation "com.android.billingclient:billing:dp-1"
implementation "com.google.firebase:firebase-core:16.0.5"
implementation "com.google.firebase:firebase-ads:17.0.0"
implementation 'com.crashlytics.sdk.android:crashlytics:2.9.5'

implementation fileTree(include: ['*.jar'], dir: 'libs')
}

// ADD THIS AT THE BOTTOM
apply plugin: 'com.google.gms.google-services'


:android_instant_feature



apply plugin: "com.android.feature"

android {
// baseFeature true
buildToolsVersion "28.0.2"
compileSdkVersion 28
sourceSets {
main {
manifest.srcFile 'AndroidManifest.xml'
java.srcDirs = ['src']
aidl.srcDirs = ['src']
renderscript.srcDirs = ['src']
res.srcDirs = ["${project(':android_common').projectDir}/res"]
assets.srcDirs = ['assets']
jniLibs.srcDirs = ['libs']
}
}
defaultConfig {
versionCode 4031
versionName "4.1.2.1i"
minSdkVersion 16
targetSdkVersion 28
multiDexEnabled true
}

dexOptions {
jumboMode true
}

// Proguard configuration
buildTypes {
release {
//minifyEnabled true will turn proguard ON
// minifyEnabled true
//proguardFiles let you add your own proguard rules ('proguard-project.txt') in this case, as its already created by gdx-setup
// proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-project.txt'
}
debug {}
}


compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
productFlavors {
}
lintOptions {
abortOnError false
}
}

task run(type: Exec) {
def path
def localProperties = project.file("../local.properties")
if (localProperties.exists()) {
Properties properties = new Properties()
localProperties.withInputStream { instr ->
properties.load(instr)
}
def sdkDir = properties.getProperty('sdk.dir')
if (sdkDir) {
path = sdkDir
} else {
path = "$System.env.ANDROID_HOME"
}
} else {
path = "$System.env.ANDROID_HOME"
}

def adb = path + "/platform-tools/adb"
commandLine "$adb", 'shell', 'am', 'start', '-n', 'com.myapp.id/com.myapp.id.AndroidLauncher'
}

dependencies {
implementation project(":android_common")
api 'com.android.support:multidex:1.0.3'
implementation "com.badlogicgames.gdx:gdx-backend-android:1.9.9-SNAPSHOT"
implementation "com.badlogicgames.gdx:gdx-freetype:1.9.9-SNAPSHOT"
implementation "com.google.firebase:firebase-core:16.0.5"
implementation 'com.google.android.gms:play-services-instantapps:16.0.1'

implementation fileTree(dir: 'libs', include: ['*.jar'])
}

// ADD THIS AT THE BOTTOM
apply plugin: 'com.google.gms.google-services'


Finally, this is the structure of my project. The most relevant part as it's android related is the one on the top. Below I just show how it's related to the core module.



enter image description here



This is a libGDX game and I'm working with IntelliJ Idea, though this is not relevant since I'm getting these errors with ./gradlew build in the command line.





EDIT: I downgraded firebase-core from 16.0.5 to 16.0.4 as suggested by TWL and it worked, so I think it's an acceptable workaround, at least while the firebase guys release a firebase-core 16.0.6 or so actually compatible with firebase-ads 17.0.0. The problem seems to be effectively that firebase-ads 17.0.0 relies on a older version of the library that's causing the error.



Look at these dependencies outputs:



This is what I get with firebase-core 16.0.4:



$ ./gradlew android_common:dependencies | grep measurement-base
<-------------> 0% EXECUTING [0s]
> :android_common:dependencies
| | | +--- com.google.android.gms:play-services-measurement-base:16.0.3
| | | | +--- com.google.android.gms:play-services-measurement-base:16.0.3
| | +--- com.google.android.gms:play-services-measurement-base:16.0.3
| +--- com.google.android.gms:play-services-measurement-base:16.0.3
| | | --- com.google.android.gms:play-services-measurement-base:16.0.3
| | | +--- com.google.android.gms:play-services-measurement-base:16.0.3
| | | | +--- com.google.android.gms:play-services-measurement-base:16.0.3
| | +--- com.google.android.gms:play-services-measurement-base:16.0.3
| +--- com.google.android.gms:play-services-measurement-base:16.0.3
| | | --- com.google.android.gms:play-services-measurement-base:16.0.3
| | | +--- com.google.android.gms:play-services-measurement-base:16.0.3
| | | | +--- com.google.android.gms:play-services-measurement-base:16.0.3
| | +--- com.google.android.gms:play-services-measurement-base:16.0.3
| +--- com.google.android.gms:play-services-measurement-base:16.0.3


... (and so on, all 16.0.3 straight forward)



And this for firebase-core 16.0.5:



$ ./gradlew android_common:dependencies | grep measurement-base
<-------------> 0% EXECUTING [1s]
> :android_common:dependencies > Resolve dependencies of :android_common:releaseUnitTestRuntimeClasspath
| | | +--- com.google.android.gms:play-services-measurement-base:[16.0.4] -> 16.0.4
| | | | +--- com.google.android.gms:play-services-measurement-base:[16.0.4] -> 16.0.4 (*)
| | +--- com.google.android.gms:play-services-measurement-base:[16.0.4] -> 16.0.4 (*)
| +--- com.google.android.gms:play-services-measurement-base:[16.0.4] -> 16.0.4 (*)
| | | --- com.google.android.gms:play-services-measurement-base:16.0.3 -> 16.0.4 (*)
| | | +--- com.google.android.gms:play-services-measurement-base:[16.0.4] -> 16.0.4
| | | | +--- com.google.android.gms:play-services-measurement-base:[16.0.4] -> 16.0.4 (*)
| | +--- com.google.android.gms:play-services-measurement-base:[16.0.4] -> 16.0.4 (*)
| +--- com.google.android.gms:play-services-measurement-base:[16.0.4] -> 16.0.4 (*)
| | | --- com.google.android.gms:play-services-measurement-base:16.0.3 -> 16.0.4 (*)
| | | +--- com.google.android.gms:play-services-measurement-base:[16.0.4] -> 16.0.4
| | | | +--- com.google.android.gms:play-services-measurement-base:[16.0.4] -> 16.0.4 (*)
| | +--- com.google.android.gms:play-services-measurement-base:[16.0.4] -> 16.0.4 (*)
| +--- com.google.android.gms:play-services-measurement-base:[16.0.4] -> 16.0.4 (*)
| | | --- com.google.android.gms:play-services-measurement-base:16.0.3 -> 16.0.4 (*)
| | | +--- com.google.android.gms:play-services-measurement-base:[16.0.4] -> 16.0.4
| | | | +--- com.google.android.gms:play-services-measurement-base:[16.0.4] -> 16.0.4 (*)
| | +--- com.google.android.gms:play-services-measurement-base:[16.0.4] -> 16.0.4 (*)
| +--- com.google.android.gms:play-services-measurement-base:[16.0.4] -> 16.0.4 (*)
| | | --- com.google.android.gms:play-services-measurement-base:16.0.3 -> 16.0.4 (*)
| | | +--- com.google.android.gms:play-services-measurement-base:[16.0.4] -> 16.0.4
| | | | +--- com.google.android.gms:play-services-measurement-base:[16.0.4] -> 16.0.4 (*)
| | +--- com.google.android.gms:play-services-measurement-base:[16.0.4] -> 16.0.4 (*)
| +--- com.google.android.gms:play-services-measurement-base:[16.0.4] -> 16.0.4 (*)
| | | --- com.google.android.gms:play-services-measurement-base:16.0.3 -> 16.0.4 (*)
| | | +--- com.google.android.gms:play-services-measurement-base:[16.0.4] -> 16.0.4
| | | | +--- com.google.android.gms:play-services-measurement-base:[16.0.4] -> 16.0.4 (*)
| | +--- com.google.android.gms:play-services-measurement-base:[16.0.4] -> 16.0.4 (*)
| +--- com.google.android.gms:play-services-measurement-base:[16.0.4] -> 16.0.4 (*)
| | | --- com.google.android.gms:play-services-measurement-base:16.0.3 -> 16.0.4 (*)
| | | +--- com.google.android.gms:play-services-measurement-base:[16.0.4] -> 16.0.4
| | | | +--- com.google.android.gms:play-services-measurement-base:[16.0.4] -> 16.0.4 (*)
| | +--- com.google.android.gms:play-services-measurement-base:[16.0.4] -> 16.0.4 (*)
| +--- com.google.android.gms:play-services-measurement-base:[16.0.4] -> 16.0.4 (*)
| | | --- com.google.android.gms:play-services-measurement-base:16.0.3 -> 16.0.4 (*)
| | | +--- com.google.android.gms:play-services-measurement-base:[16.0.4] -> 16.0.4
| | | | +--- com.google.android.gms:play-services-measurement-base:[16.0.4] -> 16.0.4 (*)
| | +--- com.google.android.gms:play-services-measurement-base:[16.0.4] -> 16.0.4 (*)
| +--- com.google.android.gms:play-services-measurement-base:[16.0.4] -> 16.0.4 (*)
| | | --- com.google.android.gms:play-services-measurement-base:16.0.3 -> 16.0.4 (*)
| | | +--- com.google.android.gms:play-services-measurement-base:[16.0.4] -> 16.0.4
| | | | +--- com.google.android.gms:play-services-measurement-base:[16.0.4] -> 16.0.4 (*)
| | +--- com.google.android.gms:play-services-measurement-base:[16.0.4] -> 16.0.4 (*)
| +--- com.google.android.gms:play-services-measurement-base:[16.0.4] -> 16.0.4 (*)
| | | --- com.google.android.gms:play-services-measurement-base:16.0.3 -> 16.0.4 (*)
| | | +--- com.google.android.gms:play-services-measurement-base:[16.0.4] -> 16.0.4
| | | | +--- com.google.android.gms:play-services-measurement-base:[16.0.4] -> 16.0.4 (*)
| | +--- com.google.android.gms:play-services-measurement-base:[16.0.4] -> 16.0.4 (*)
| +--- com.google.android.gms:play-services-measurement-base:[16.0.4] -> 16.0.4 (*)
| | | --- com.google.android.gms:play-services-measurement-base:16.0.3 -> 16.0.4 (*)
| | | +--- com.google.android.gms:play-services-measurement-base:[16.0.4] -> 16.0.4
| | | | +--- com.google.android.gms:play-services-measurement-base:[16.0.4] -> 16.0.4 (*)
| | +--- com.google.android.gms:play-services-measurement-base:[16.0.4] -> 16.0.4 (*)
| +--- com.google.android.gms:play-services-measurement-base:[16.0.4] -> 16.0.4 (*)
| | | --- com.google.android.gms:play-services-measurement-base:16.0.3 -> 16.0.4 (*)
| | | +--- com.google.android.gms:play-services-measurement-base:[16.0.4] -> 16.0.4
| | | | +--- com.google.android.gms:play-services-measurement-base:[16.0.4] -> 16.0.4 (*)
| | +--- com.google.android.gms:play-services-measurement-base:[16.0.4] -> 16.0.4 (*)
| +--- com.google.android.gms:play-services-measurement-base:[16.0.4] -> 16.0.4 (*)
| | | --- com.google.android.gms:play-services-measurement-base:16.0.3 -> 16.0.4 (*)
| | | +--- com.google.android.gms:play-services-measurement-base:[16.0.4] -> 16.0.4
| | | | +--- com.google.android.gms:play-services-measurement-base:[16.0.4] -> 16.0.4 (*)
| | +--- com.google.android.gms:play-services-measurement-base:[16.0.4] -> 16.0.4 (*)
| +--- com.google.android.gms:play-services-measurement-base:[16.0.4] -> 16.0.4 (*)
| | | --- com.google.android.gms:play-services-measurement-base:16.0.3 -> 16.0.4 (*)
| | | +--- com.google.android.gms:play-services-measurement-base:[16.0.4] -> 16.0.4
| | | | +--- com.google.android.gms:play-services-measurement-base:[16.0.4] -> 16.0.4 (*)
| | +--- com.google.android.gms:play-services-measurement-base:[16.0.4] -> 16.0.4 (*)
| +--- com.google.android.gms:play-services-measurement-base:[16.0.4] -> 16.0.4 (*)
| | | --- com.google.android.gms:play-services-measurement-base:16.0.3 -> 16.0.4 (*)
| | | +--- com.google.android.gms:play-services-measurement-base:[16.0.4] -> 16.0.4
| | | | +--- com.google.android.gms:play-services-measurement-base:[16.0.4] -> 16.0.4 (*)
| | +--- com.google.android.gms:play-services-measurement-base:[16.0.4] -> 16.0.4 (*)


As you see, there are some entries like "com.google.android.gms:play-services-measurement-base:16.0.3 -> 16.0.4 (*)" that, despite I'm not proficient on interpreting these outputs, I think are the cause of the issue.










share|improve this question
























  • Comments are not for extended discussion; this conversation has been moved to chat.
    – Samuel Liew
    Nov 9 at 8:30















up vote
1
down vote

favorite












I have an app that builds just fine, but starts failing as soon as I try to update some Gradle dependencies, whereas the main suspect is firebase.



This is the error I'm getting:




Caused by:
com.android.builder.multidex.D8MainDexList$MainDexListException:
com.android.tools.r8.errors.CompilationError: Program type already
present: com.google.android.gms.internal.measurement.zzdz




And this is the git diff for my project, showing the differences in the Gradle files:



diff --git a/android/build.gradle b/android/build.gradle
index 9f63f745..08fda2eb 100644
--- a/android/build.gradle
+++ b/android/build.gradle
@@ -81,8 +81,8 @@ dependencies {
implementation "com.badlogicgames.gdx:gdx-backend-android:$gdxVersion"
implementation "com.badlogicgames.gdx:gdx-freetype:$gdxVersion"
implementation "com.android.billingclient:billing:$playBillingLibVersion"
- implementation "com.google.firebase:firebase-core:16.0.3"
- implementation "com.google.firebase:firebase-ads:15.0.1"
+ implementation "com.google.firebase:firebase-core:16.0.5"
+ implementation "com.google.firebase:firebase-ads:17.0.0"
implementation 'com.crashlytics.sdk.android:crashlytics:2.9.5'

implementation fileTree(include: ['*.jar'], dir: 'libs')
diff --git a/android_common/build.gradle b/android_common/build.gradle
index f8224509..3a5d45e1 100644
--- a/android_common/build.gradle
+++ b/android_common/build.gradle
@@ -19,7 +19,7 @@ android {
androidTest.setRoot('tests')
}
defaultConfig {
- minSdkVersion 15
+ minSdkVersion 16
targetSdkVersion 28
versionCode 1
versionName "1.0"
@@ -65,8 +65,8 @@ dependencies {
natives "com.badlogicgames.gdx:gdx-freetype-platform:$gdxVersion:natives-x86"
natives "com.badlogicgames.gdx:gdx-freetype-platform:$gdxVersion:natives-x86_64"
implementation "com.android.billingclient:billing:$playBillingLibVersion"
- implementation "com.google.firebase:firebase-core:16.0.3"
- implementation "com.google.firebase:firebase-ads:15.0.1"
+ implementation "com.google.firebase:firebase-core:16.0.5"
+ implementation "com.google.firebase:firebase-ads:17.0.0"

implementation fileTree(include: ['*.jar'], dir: 'libs')
testImplementation 'junit:junit:4.12'
diff --git a/android_instant_feature/build.gradle b/android_instant_feature/build.gradle
index 30431c11..17c4ef27 100644
--- a/android_instant_feature/build.gradle
+++ b/android_instant_feature/build.gradle
@@ -18,7 +18,7 @@ android {
defaultConfig {
versionCode 4031
versionName "4.1.2.1i"
- minSdkVersion 15
+ minSdkVersion 16
targetSdkVersion 28
multiDexEnabled true
}
@@ -77,8 +77,8 @@ dependencies {
api 'com.android.support:multidex:1.0.3'
implementation "com.badlogicgames.gdx:gdx-backend-android:$gdxVersion"
implementation "com.badlogicgames.gdx:gdx-freetype:$gdxVersion"
- implementation "com.google.firebase:firebase-core:16.0.3"
- implementation 'com.google.android.gms:play-services-instantapps:16.0.0'
+ implementation "com.google.firebase:firebase-core:16.0.5"
+ implementation 'com.google.android.gms:play-services-instantapps:16.0.1'

implementation fileTree(dir: 'libs', include: ['*.jar'])
}
diff --git a/core/build.gradle b/core/build.gradle
index dd2640cf..5694a1da 100644
--- a/core/build.gradle
+++ b/core/build.gradle
@@ -15,7 +15,7 @@ dependencies {
compile group: 'commons-io', name: 'commons-io', version: '2.6'
// https://mvnrepository.com/artifact/commons-codec/commons-codec
compile group: 'commons-codec', name: 'commons-codec', version: '1.11'
- compile 'com.google.code.gson:gson:2.8.2'
+ compile 'com.google.code.gson:gson:2.8.5'
compile group: 'org.apache.commons', name: 'commons-text', version: '1.2'
compile group: 'org.apache.commons', name: 'commons-collections4', version: '4.1'
compile group: 'org.jetbrains', name: 'annotations', version: '16.0.1'
@@ -23,7 +23,7 @@ dependencies {
implementation "com.badlogicgames.gdx:gdx-freetype:$gdxVersion"

testCompile 'junit:junit:4.12'
- testCompile 'org.mockito:mockito-core:2.7.22'
+ testCompile 'org.mockito:mockito-core:2.8.9'
testCompile group: 'org.powermock', name: 'powermock-api-mockito2', version: '1.7.3'
testCompile group: 'org.powermock', name: 'powermock-module-junit4', version: '1.7.3'
}


Please, note that some of these changes like the minSDKVersion can be discarded as the source of the error. It seems most likely it is related to firebase. Why? Well, among other things there are other questions in Stackoverflow in which that's the case, however the solution proposed in all of these is to update firebase dependencies to last version, but updating firebase dependencies to last version is what it seems to be causing the problem in my project! With the old versions it just builds fine.



These are the contents of the Gradle scripts involved (I have replaced the actual applicationId with 'com.myapp.id')



:core



apply plugin: "java"

targetCompatibility = 1.8
sourceCompatibility = 1.8
[compileJava, compileTestJava]*.options*.encoding = 'UTF-8'

sourceSets.main.java.srcDirs = ["src/main"]
sourceSets.test.java.srcDirs = ["src/test"]

dependencies {
compile 'commons-io:commons-io:2.6'
compile 'commons-codec:commons-codec:1.11'
compile 'com.google.code.gson:gson:2.8.5'
compile 'org.apache.commons:commons-text:1.2'
compile 'org.apache.commons:commons-collections4:4.1'
compile 'org.jetbrains:annotations:16.0.1'
compile "com.badlogicgames.gdx:gdx:1.9.9-SNAPSHOT"
compile "com.badlogicgames.gdx:gdx-freetype:1.9.9-SNAPSHOT"

testCompile 'junit:junit:4.12'
testCompile 'org.mockito:mockito-core:2.8.9'
testCompile 'org.powermock:powermock-api-mockito2:1.7.3'
testCompile 'org.powermock:powermock-module-junit4:1.7.3'
}


repositories {
mavenCentral()
}

jar {
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
}


:android_common



apply plugin: "com.android.feature"

configurations { natives }

android {
baseFeature true
compileSdkVersion 28
sourceSets {
main {
manifest.srcFile 'AndroidManifest.xml'
java.srcDirs = ['src']
aidl.srcDirs = ['src']
renderscript.srcDirs = ['src']
res.srcDirs = ['res']
assets.srcDirs = ['assets']
jniLibs.srcDirs = ['libs']
}

androidTest.setRoot('tests')
}
defaultConfig {
minSdkVersion 16
targetSdkVersion 28
versionCode 1
versionName "1.0"

testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
sourceSets {
all {
manifest.srcFile "AndroidManifest.xml"
}
}
multiDexEnabled true
}
buildTypes {
release {
setMinifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
buildToolsVersion '28.0.2'
lintOptions {
abortOnError false
}
dexOptions {
jumboMode true
}
}

dependencies {
application project(':android')
feature project(':android_instant_feature')
api project(':core')
api 'com.android.support:multidex:1.0.3'
implementation "com.badlogicgames.gdx:gdx-backend-android:1.9.9-SNAPSHOT"
natives "com.badlogicgames.gdx:gdx-platform:1.9.9-SNAPSHOT:natives-armeabi"
natives "com.badlogicgames.gdx:gdx-platform:1.9.9-SNAPSHOT:natives-armeabi-v7a"
natives "com.badlogicgames.gdx:gdx-platform:1.9.9-SNAPSHOT:natives-arm64-v8a"
natives "com.badlogicgames.gdx:gdx-platform:1.9.9-SNAPSHOT:natives-x86"
natives "com.badlogicgames.gdx:gdx-platform:1.9.9-SNAPSHOT:natives-x86_64"
implementation "com.badlogicgames.gdx:gdx-freetype:1.9.9-SNAPSHOT"
natives "com.badlogicgames.gdx:gdx-freetype-platform:1.9.9-SNAPSHOT:natives-armeabi"
natives "com.badlogicgames.gdx:gdx-freetype-platform:1.9.9-SNAPSHOT:natives-armeabi-v7a"
natives "com.badlogicgames.gdx:gdx-freetype-platform:1.9.9-SNAPSHOT:natives-arm64-v8a"
natives "com.badlogicgames.gdx:gdx-freetype-platform:1.9.9-SNAPSHOT:natives-x86"
natives "com.badlogicgames.gdx:gdx-freetype-platform:1.9.9-SNAPSHOT:natives-x86_64"
implementation "com.android.billingclient:billing:dp-1"
implementation "com.google.firebase:firebase-core:16.0.5"
implementation "com.google.firebase:firebase-ads:17.0.0"

implementation fileTree(include: ['*.jar'], dir: 'libs')
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
implementation 'com.google.guava:guava:24.0-android'
}

task copyAndroidNatives() {
file("libs/armeabi/").mkdirs();
file("libs/armeabi-v7a/").mkdirs();
file("libs/arm64-v8a/").mkdirs();
file("libs/x86_64/").mkdirs();
file("libs/x86/").mkdirs();

configurations.natives.files.each { jar ->
def outputDir = null
if (jar.name.endsWith("natives-arm64-v8a.jar")) outputDir = file("libs/arm64-v8a")
if (jar.name.endsWith("natives-armeabi-v7a.jar")) outputDir = file("libs/armeabi-v7a")
if (jar.name.endsWith("natives-armeabi.jar")) outputDir = file("libs/armeabi")
if (jar.name.endsWith("natives-x86_64.jar")) outputDir = file("libs/x86_64")
if (jar.name.endsWith("natives-x86.jar")) outputDir = file("libs/x86")
if (outputDir != null) {
copy {
from zipTree(jar)
into outputDir
include "*.so"
}
}
}
}


:android



apply plugin: "com.android.application"
apply plugin: 'io.fabric' // Needed by crashlytics. DO NOT REMOVE.

android {
buildToolsVersion "28.0.2"
compileSdkVersion 28
sourceSets {
main {
manifest.srcFile 'AndroidManifest.xml'
java.srcDirs = ['src']
aidl.srcDirs = ['src']
renderscript.srcDirs = ['src']
res.srcDirs = ["${project(':android_common').projectDir}/res"]
assets.srcDirs = ['assets']
jniLibs.srcDirs = ['libs']
}

androidTest.setRoot('tests')
}
defaultConfig {
applicationId "com.myapp.id"
versionCode 4032
versionName "4.1.2.1"
minSdkVersion 16
targetSdkVersion 28
multiDexEnabled true
}
dexOptions {
jumboMode true
}
// Proguard configuration
buildTypes {
release {
//minifyEnabled true will turn proguard ON
minifyEnabled true
//proguardFiles let you add your own proguard rules ('proguard-project.txt') in this case, as its already created by gdx-setup
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-project.txt'
}
}

compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
productFlavors {
}
lintOptions {
abortOnError false
}
}

task importPuzzles(type: Exec) {
// TODO
}

task run(type: Exec) {
def path
def localProperties = project.file("../local.properties")
if (localProperties.exists()) {
Properties properties = new Properties()
localProperties.withInputStream { instr ->
properties.load(instr)
}
def sdkDir = properties.getProperty('sdk.dir')
if (sdkDir) {
path = sdkDir
} else {
path = "$System.env.ANDROID_HOME"
}
} else {
path = "$System.env.ANDROID_HOME"
}

def adb = path + "/platform-tools/adb"
commandLine "$adb", 'shell', 'am', 'start', '-n', 'com.myapp.id/com.myapp.id.AndroidLauncher'
}

dependencies {
implementation project(":android_common")
api 'com.android.support:multidex:1.0.3'
implementation "com.badlogicgames.gdx:gdx-backend-android:1.9.9-SNAPSHOT"
implementation "com.badlogicgames.gdx:gdx-freetype:1.9.9-SNAPSHOT"
implementation "com.android.billingclient:billing:dp-1"
implementation "com.google.firebase:firebase-core:16.0.5"
implementation "com.google.firebase:firebase-ads:17.0.0"
implementation 'com.crashlytics.sdk.android:crashlytics:2.9.5'

implementation fileTree(include: ['*.jar'], dir: 'libs')
}

// ADD THIS AT THE BOTTOM
apply plugin: 'com.google.gms.google-services'


:android_instant_feature



apply plugin: "com.android.feature"

android {
// baseFeature true
buildToolsVersion "28.0.2"
compileSdkVersion 28
sourceSets {
main {
manifest.srcFile 'AndroidManifest.xml'
java.srcDirs = ['src']
aidl.srcDirs = ['src']
renderscript.srcDirs = ['src']
res.srcDirs = ["${project(':android_common').projectDir}/res"]
assets.srcDirs = ['assets']
jniLibs.srcDirs = ['libs']
}
}
defaultConfig {
versionCode 4031
versionName "4.1.2.1i"
minSdkVersion 16
targetSdkVersion 28
multiDexEnabled true
}

dexOptions {
jumboMode true
}

// Proguard configuration
buildTypes {
release {
//minifyEnabled true will turn proguard ON
// minifyEnabled true
//proguardFiles let you add your own proguard rules ('proguard-project.txt') in this case, as its already created by gdx-setup
// proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-project.txt'
}
debug {}
}


compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
productFlavors {
}
lintOptions {
abortOnError false
}
}

task run(type: Exec) {
def path
def localProperties = project.file("../local.properties")
if (localProperties.exists()) {
Properties properties = new Properties()
localProperties.withInputStream { instr ->
properties.load(instr)
}
def sdkDir = properties.getProperty('sdk.dir')
if (sdkDir) {
path = sdkDir
} else {
path = "$System.env.ANDROID_HOME"
}
} else {
path = "$System.env.ANDROID_HOME"
}

def adb = path + "/platform-tools/adb"
commandLine "$adb", 'shell', 'am', 'start', '-n', 'com.myapp.id/com.myapp.id.AndroidLauncher'
}

dependencies {
implementation project(":android_common")
api 'com.android.support:multidex:1.0.3'
implementation "com.badlogicgames.gdx:gdx-backend-android:1.9.9-SNAPSHOT"
implementation "com.badlogicgames.gdx:gdx-freetype:1.9.9-SNAPSHOT"
implementation "com.google.firebase:firebase-core:16.0.5"
implementation 'com.google.android.gms:play-services-instantapps:16.0.1'

implementation fileTree(dir: 'libs', include: ['*.jar'])
}

// ADD THIS AT THE BOTTOM
apply plugin: 'com.google.gms.google-services'


Finally, this is the structure of my project. The most relevant part as it's android related is the one on the top. Below I just show how it's related to the core module.



enter image description here



This is a libGDX game and I'm working with IntelliJ Idea, though this is not relevant since I'm getting these errors with ./gradlew build in the command line.





EDIT: I downgraded firebase-core from 16.0.5 to 16.0.4 as suggested by TWL and it worked, so I think it's an acceptable workaround, at least while the firebase guys release a firebase-core 16.0.6 or so actually compatible with firebase-ads 17.0.0. The problem seems to be effectively that firebase-ads 17.0.0 relies on a older version of the library that's causing the error.



Look at these dependencies outputs:



This is what I get with firebase-core 16.0.4:



$ ./gradlew android_common:dependencies | grep measurement-base
<-------------> 0% EXECUTING [0s]
> :android_common:dependencies
| | | +--- com.google.android.gms:play-services-measurement-base:16.0.3
| | | | +--- com.google.android.gms:play-services-measurement-base:16.0.3
| | +--- com.google.android.gms:play-services-measurement-base:16.0.3
| +--- com.google.android.gms:play-services-measurement-base:16.0.3
| | | --- com.google.android.gms:play-services-measurement-base:16.0.3
| | | +--- com.google.android.gms:play-services-measurement-base:16.0.3
| | | | +--- com.google.android.gms:play-services-measurement-base:16.0.3
| | +--- com.google.android.gms:play-services-measurement-base:16.0.3
| +--- com.google.android.gms:play-services-measurement-base:16.0.3
| | | --- com.google.android.gms:play-services-measurement-base:16.0.3
| | | +--- com.google.android.gms:play-services-measurement-base:16.0.3
| | | | +--- com.google.android.gms:play-services-measurement-base:16.0.3
| | +--- com.google.android.gms:play-services-measurement-base:16.0.3
| +--- com.google.android.gms:play-services-measurement-base:16.0.3


... (and so on, all 16.0.3 straight forward)



And this for firebase-core 16.0.5:



$ ./gradlew android_common:dependencies | grep measurement-base
<-------------> 0% EXECUTING [1s]
> :android_common:dependencies > Resolve dependencies of :android_common:releaseUnitTestRuntimeClasspath
| | | +--- com.google.android.gms:play-services-measurement-base:[16.0.4] -> 16.0.4
| | | | +--- com.google.android.gms:play-services-measurement-base:[16.0.4] -> 16.0.4 (*)
| | +--- com.google.android.gms:play-services-measurement-base:[16.0.4] -> 16.0.4 (*)
| +--- com.google.android.gms:play-services-measurement-base:[16.0.4] -> 16.0.4 (*)
| | | --- com.google.android.gms:play-services-measurement-base:16.0.3 -> 16.0.4 (*)
| | | +--- com.google.android.gms:play-services-measurement-base:[16.0.4] -> 16.0.4
| | | | +--- com.google.android.gms:play-services-measurement-base:[16.0.4] -> 16.0.4 (*)
| | +--- com.google.android.gms:play-services-measurement-base:[16.0.4] -> 16.0.4 (*)
| +--- com.google.android.gms:play-services-measurement-base:[16.0.4] -> 16.0.4 (*)
| | | --- com.google.android.gms:play-services-measurement-base:16.0.3 -> 16.0.4 (*)
| | | +--- com.google.android.gms:play-services-measurement-base:[16.0.4] -> 16.0.4
| | | | +--- com.google.android.gms:play-services-measurement-base:[16.0.4] -> 16.0.4 (*)
| | +--- com.google.android.gms:play-services-measurement-base:[16.0.4] -> 16.0.4 (*)
| +--- com.google.android.gms:play-services-measurement-base:[16.0.4] -> 16.0.4 (*)
| | | --- com.google.android.gms:play-services-measurement-base:16.0.3 -> 16.0.4 (*)
| | | +--- com.google.android.gms:play-services-measurement-base:[16.0.4] -> 16.0.4
| | | | +--- com.google.android.gms:play-services-measurement-base:[16.0.4] -> 16.0.4 (*)
| | +--- com.google.android.gms:play-services-measurement-base:[16.0.4] -> 16.0.4 (*)
| +--- com.google.android.gms:play-services-measurement-base:[16.0.4] -> 16.0.4 (*)
| | | --- com.google.android.gms:play-services-measurement-base:16.0.3 -> 16.0.4 (*)
| | | +--- com.google.android.gms:play-services-measurement-base:[16.0.4] -> 16.0.4
| | | | +--- com.google.android.gms:play-services-measurement-base:[16.0.4] -> 16.0.4 (*)
| | +--- com.google.android.gms:play-services-measurement-base:[16.0.4] -> 16.0.4 (*)
| +--- com.google.android.gms:play-services-measurement-base:[16.0.4] -> 16.0.4 (*)
| | | --- com.google.android.gms:play-services-measurement-base:16.0.3 -> 16.0.4 (*)
| | | +--- com.google.android.gms:play-services-measurement-base:[16.0.4] -> 16.0.4
| | | | +--- com.google.android.gms:play-services-measurement-base:[16.0.4] -> 16.0.4 (*)
| | +--- com.google.android.gms:play-services-measurement-base:[16.0.4] -> 16.0.4 (*)
| +--- com.google.android.gms:play-services-measurement-base:[16.0.4] -> 16.0.4 (*)
| | | --- com.google.android.gms:play-services-measurement-base:16.0.3 -> 16.0.4 (*)
| | | +--- com.google.android.gms:play-services-measurement-base:[16.0.4] -> 16.0.4
| | | | +--- com.google.android.gms:play-services-measurement-base:[16.0.4] -> 16.0.4 (*)
| | +--- com.google.android.gms:play-services-measurement-base:[16.0.4] -> 16.0.4 (*)
| +--- com.google.android.gms:play-services-measurement-base:[16.0.4] -> 16.0.4 (*)
| | | --- com.google.android.gms:play-services-measurement-base:16.0.3 -> 16.0.4 (*)
| | | +--- com.google.android.gms:play-services-measurement-base:[16.0.4] -> 16.0.4
| | | | +--- com.google.android.gms:play-services-measurement-base:[16.0.4] -> 16.0.4 (*)
| | +--- com.google.android.gms:play-services-measurement-base:[16.0.4] -> 16.0.4 (*)
| +--- com.google.android.gms:play-services-measurement-base:[16.0.4] -> 16.0.4 (*)
| | | --- com.google.android.gms:play-services-measurement-base:16.0.3 -> 16.0.4 (*)
| | | +--- com.google.android.gms:play-services-measurement-base:[16.0.4] -> 16.0.4
| | | | +--- com.google.android.gms:play-services-measurement-base:[16.0.4] -> 16.0.4 (*)
| | +--- com.google.android.gms:play-services-measurement-base:[16.0.4] -> 16.0.4 (*)
| +--- com.google.android.gms:play-services-measurement-base:[16.0.4] -> 16.0.4 (*)
| | | --- com.google.android.gms:play-services-measurement-base:16.0.3 -> 16.0.4 (*)
| | | +--- com.google.android.gms:play-services-measurement-base:[16.0.4] -> 16.0.4
| | | | +--- com.google.android.gms:play-services-measurement-base:[16.0.4] -> 16.0.4 (*)
| | +--- com.google.android.gms:play-services-measurement-base:[16.0.4] -> 16.0.4 (*)
| +--- com.google.android.gms:play-services-measurement-base:[16.0.4] -> 16.0.4 (*)
| | | --- com.google.android.gms:play-services-measurement-base:16.0.3 -> 16.0.4 (*)
| | | +--- com.google.android.gms:play-services-measurement-base:[16.0.4] -> 16.0.4
| | | | +--- com.google.android.gms:play-services-measurement-base:[16.0.4] -> 16.0.4 (*)
| | +--- com.google.android.gms:play-services-measurement-base:[16.0.4] -> 16.0.4 (*)
| +--- com.google.android.gms:play-services-measurement-base:[16.0.4] -> 16.0.4 (*)
| | | --- com.google.android.gms:play-services-measurement-base:16.0.3 -> 16.0.4 (*)
| | | +--- com.google.android.gms:play-services-measurement-base:[16.0.4] -> 16.0.4
| | | | +--- com.google.android.gms:play-services-measurement-base:[16.0.4] -> 16.0.4 (*)
| | +--- com.google.android.gms:play-services-measurement-base:[16.0.4] -> 16.0.4 (*)
| +--- com.google.android.gms:play-services-measurement-base:[16.0.4] -> 16.0.4 (*)
| | | --- com.google.android.gms:play-services-measurement-base:16.0.3 -> 16.0.4 (*)
| | | +--- com.google.android.gms:play-services-measurement-base:[16.0.4] -> 16.0.4
| | | | +--- com.google.android.gms:play-services-measurement-base:[16.0.4] -> 16.0.4 (*)
| | +--- com.google.android.gms:play-services-measurement-base:[16.0.4] -> 16.0.4 (*)
| +--- com.google.android.gms:play-services-measurement-base:[16.0.4] -> 16.0.4 (*)
| | | --- com.google.android.gms:play-services-measurement-base:16.0.3 -> 16.0.4 (*)
| | | +--- com.google.android.gms:play-services-measurement-base:[16.0.4] -> 16.0.4
| | | | +--- com.google.android.gms:play-services-measurement-base:[16.0.4] -> 16.0.4 (*)
| | +--- com.google.android.gms:play-services-measurement-base:[16.0.4] -> 16.0.4 (*)
| +--- com.google.android.gms:play-services-measurement-base:[16.0.4] -> 16.0.4 (*)
| | | --- com.google.android.gms:play-services-measurement-base:16.0.3 -> 16.0.4 (*)
| | | +--- com.google.android.gms:play-services-measurement-base:[16.0.4] -> 16.0.4
| | | | +--- com.google.android.gms:play-services-measurement-base:[16.0.4] -> 16.0.4 (*)
| | +--- com.google.android.gms:play-services-measurement-base:[16.0.4] -> 16.0.4 (*)


As you see, there are some entries like "com.google.android.gms:play-services-measurement-base:16.0.3 -> 16.0.4 (*)" that, despite I'm not proficient on interpreting these outputs, I think are the cause of the issue.










share|improve this question
























  • Comments are not for extended discussion; this conversation has been moved to chat.
    – Samuel Liew
    Nov 9 at 8:30













up vote
1
down vote

favorite









up vote
1
down vote

favorite











I have an app that builds just fine, but starts failing as soon as I try to update some Gradle dependencies, whereas the main suspect is firebase.



This is the error I'm getting:




Caused by:
com.android.builder.multidex.D8MainDexList$MainDexListException:
com.android.tools.r8.errors.CompilationError: Program type already
present: com.google.android.gms.internal.measurement.zzdz




And this is the git diff for my project, showing the differences in the Gradle files:



diff --git a/android/build.gradle b/android/build.gradle
index 9f63f745..08fda2eb 100644
--- a/android/build.gradle
+++ b/android/build.gradle
@@ -81,8 +81,8 @@ dependencies {
implementation "com.badlogicgames.gdx:gdx-backend-android:$gdxVersion"
implementation "com.badlogicgames.gdx:gdx-freetype:$gdxVersion"
implementation "com.android.billingclient:billing:$playBillingLibVersion"
- implementation "com.google.firebase:firebase-core:16.0.3"
- implementation "com.google.firebase:firebase-ads:15.0.1"
+ implementation "com.google.firebase:firebase-core:16.0.5"
+ implementation "com.google.firebase:firebase-ads:17.0.0"
implementation 'com.crashlytics.sdk.android:crashlytics:2.9.5'

implementation fileTree(include: ['*.jar'], dir: 'libs')
diff --git a/android_common/build.gradle b/android_common/build.gradle
index f8224509..3a5d45e1 100644
--- a/android_common/build.gradle
+++ b/android_common/build.gradle
@@ -19,7 +19,7 @@ android {
androidTest.setRoot('tests')
}
defaultConfig {
- minSdkVersion 15
+ minSdkVersion 16
targetSdkVersion 28
versionCode 1
versionName "1.0"
@@ -65,8 +65,8 @@ dependencies {
natives "com.badlogicgames.gdx:gdx-freetype-platform:$gdxVersion:natives-x86"
natives "com.badlogicgames.gdx:gdx-freetype-platform:$gdxVersion:natives-x86_64"
implementation "com.android.billingclient:billing:$playBillingLibVersion"
- implementation "com.google.firebase:firebase-core:16.0.3"
- implementation "com.google.firebase:firebase-ads:15.0.1"
+ implementation "com.google.firebase:firebase-core:16.0.5"
+ implementation "com.google.firebase:firebase-ads:17.0.0"

implementation fileTree(include: ['*.jar'], dir: 'libs')
testImplementation 'junit:junit:4.12'
diff --git a/android_instant_feature/build.gradle b/android_instant_feature/build.gradle
index 30431c11..17c4ef27 100644
--- a/android_instant_feature/build.gradle
+++ b/android_instant_feature/build.gradle
@@ -18,7 +18,7 @@ android {
defaultConfig {
versionCode 4031
versionName "4.1.2.1i"
- minSdkVersion 15
+ minSdkVersion 16
targetSdkVersion 28
multiDexEnabled true
}
@@ -77,8 +77,8 @@ dependencies {
api 'com.android.support:multidex:1.0.3'
implementation "com.badlogicgames.gdx:gdx-backend-android:$gdxVersion"
implementation "com.badlogicgames.gdx:gdx-freetype:$gdxVersion"
- implementation "com.google.firebase:firebase-core:16.0.3"
- implementation 'com.google.android.gms:play-services-instantapps:16.0.0'
+ implementation "com.google.firebase:firebase-core:16.0.5"
+ implementation 'com.google.android.gms:play-services-instantapps:16.0.1'

implementation fileTree(dir: 'libs', include: ['*.jar'])
}
diff --git a/core/build.gradle b/core/build.gradle
index dd2640cf..5694a1da 100644
--- a/core/build.gradle
+++ b/core/build.gradle
@@ -15,7 +15,7 @@ dependencies {
compile group: 'commons-io', name: 'commons-io', version: '2.6'
// https://mvnrepository.com/artifact/commons-codec/commons-codec
compile group: 'commons-codec', name: 'commons-codec', version: '1.11'
- compile 'com.google.code.gson:gson:2.8.2'
+ compile 'com.google.code.gson:gson:2.8.5'
compile group: 'org.apache.commons', name: 'commons-text', version: '1.2'
compile group: 'org.apache.commons', name: 'commons-collections4', version: '4.1'
compile group: 'org.jetbrains', name: 'annotations', version: '16.0.1'
@@ -23,7 +23,7 @@ dependencies {
implementation "com.badlogicgames.gdx:gdx-freetype:$gdxVersion"

testCompile 'junit:junit:4.12'
- testCompile 'org.mockito:mockito-core:2.7.22'
+ testCompile 'org.mockito:mockito-core:2.8.9'
testCompile group: 'org.powermock', name: 'powermock-api-mockito2', version: '1.7.3'
testCompile group: 'org.powermock', name: 'powermock-module-junit4', version: '1.7.3'
}


Please, note that some of these changes like the minSDKVersion can be discarded as the source of the error. It seems most likely it is related to firebase. Why? Well, among other things there are other questions in Stackoverflow in which that's the case, however the solution proposed in all of these is to update firebase dependencies to last version, but updating firebase dependencies to last version is what it seems to be causing the problem in my project! With the old versions it just builds fine.



These are the contents of the Gradle scripts involved (I have replaced the actual applicationId with 'com.myapp.id')



:core



apply plugin: "java"

targetCompatibility = 1.8
sourceCompatibility = 1.8
[compileJava, compileTestJava]*.options*.encoding = 'UTF-8'

sourceSets.main.java.srcDirs = ["src/main"]
sourceSets.test.java.srcDirs = ["src/test"]

dependencies {
compile 'commons-io:commons-io:2.6'
compile 'commons-codec:commons-codec:1.11'
compile 'com.google.code.gson:gson:2.8.5'
compile 'org.apache.commons:commons-text:1.2'
compile 'org.apache.commons:commons-collections4:4.1'
compile 'org.jetbrains:annotations:16.0.1'
compile "com.badlogicgames.gdx:gdx:1.9.9-SNAPSHOT"
compile "com.badlogicgames.gdx:gdx-freetype:1.9.9-SNAPSHOT"

testCompile 'junit:junit:4.12'
testCompile 'org.mockito:mockito-core:2.8.9'
testCompile 'org.powermock:powermock-api-mockito2:1.7.3'
testCompile 'org.powermock:powermock-module-junit4:1.7.3'
}


repositories {
mavenCentral()
}

jar {
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
}


:android_common



apply plugin: "com.android.feature"

configurations { natives }

android {
baseFeature true
compileSdkVersion 28
sourceSets {
main {
manifest.srcFile 'AndroidManifest.xml'
java.srcDirs = ['src']
aidl.srcDirs = ['src']
renderscript.srcDirs = ['src']
res.srcDirs = ['res']
assets.srcDirs = ['assets']
jniLibs.srcDirs = ['libs']
}

androidTest.setRoot('tests')
}
defaultConfig {
minSdkVersion 16
targetSdkVersion 28
versionCode 1
versionName "1.0"

testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
sourceSets {
all {
manifest.srcFile "AndroidManifest.xml"
}
}
multiDexEnabled true
}
buildTypes {
release {
setMinifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
buildToolsVersion '28.0.2'
lintOptions {
abortOnError false
}
dexOptions {
jumboMode true
}
}

dependencies {
application project(':android')
feature project(':android_instant_feature')
api project(':core')
api 'com.android.support:multidex:1.0.3'
implementation "com.badlogicgames.gdx:gdx-backend-android:1.9.9-SNAPSHOT"
natives "com.badlogicgames.gdx:gdx-platform:1.9.9-SNAPSHOT:natives-armeabi"
natives "com.badlogicgames.gdx:gdx-platform:1.9.9-SNAPSHOT:natives-armeabi-v7a"
natives "com.badlogicgames.gdx:gdx-platform:1.9.9-SNAPSHOT:natives-arm64-v8a"
natives "com.badlogicgames.gdx:gdx-platform:1.9.9-SNAPSHOT:natives-x86"
natives "com.badlogicgames.gdx:gdx-platform:1.9.9-SNAPSHOT:natives-x86_64"
implementation "com.badlogicgames.gdx:gdx-freetype:1.9.9-SNAPSHOT"
natives "com.badlogicgames.gdx:gdx-freetype-platform:1.9.9-SNAPSHOT:natives-armeabi"
natives "com.badlogicgames.gdx:gdx-freetype-platform:1.9.9-SNAPSHOT:natives-armeabi-v7a"
natives "com.badlogicgames.gdx:gdx-freetype-platform:1.9.9-SNAPSHOT:natives-arm64-v8a"
natives "com.badlogicgames.gdx:gdx-freetype-platform:1.9.9-SNAPSHOT:natives-x86"
natives "com.badlogicgames.gdx:gdx-freetype-platform:1.9.9-SNAPSHOT:natives-x86_64"
implementation "com.android.billingclient:billing:dp-1"
implementation "com.google.firebase:firebase-core:16.0.5"
implementation "com.google.firebase:firebase-ads:17.0.0"

implementation fileTree(include: ['*.jar'], dir: 'libs')
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
implementation 'com.google.guava:guava:24.0-android'
}

task copyAndroidNatives() {
file("libs/armeabi/").mkdirs();
file("libs/armeabi-v7a/").mkdirs();
file("libs/arm64-v8a/").mkdirs();
file("libs/x86_64/").mkdirs();
file("libs/x86/").mkdirs();

configurations.natives.files.each { jar ->
def outputDir = null
if (jar.name.endsWith("natives-arm64-v8a.jar")) outputDir = file("libs/arm64-v8a")
if (jar.name.endsWith("natives-armeabi-v7a.jar")) outputDir = file("libs/armeabi-v7a")
if (jar.name.endsWith("natives-armeabi.jar")) outputDir = file("libs/armeabi")
if (jar.name.endsWith("natives-x86_64.jar")) outputDir = file("libs/x86_64")
if (jar.name.endsWith("natives-x86.jar")) outputDir = file("libs/x86")
if (outputDir != null) {
copy {
from zipTree(jar)
into outputDir
include "*.so"
}
}
}
}


:android



apply plugin: "com.android.application"
apply plugin: 'io.fabric' // Needed by crashlytics. DO NOT REMOVE.

android {
buildToolsVersion "28.0.2"
compileSdkVersion 28
sourceSets {
main {
manifest.srcFile 'AndroidManifest.xml'
java.srcDirs = ['src']
aidl.srcDirs = ['src']
renderscript.srcDirs = ['src']
res.srcDirs = ["${project(':android_common').projectDir}/res"]
assets.srcDirs = ['assets']
jniLibs.srcDirs = ['libs']
}

androidTest.setRoot('tests')
}
defaultConfig {
applicationId "com.myapp.id"
versionCode 4032
versionName "4.1.2.1"
minSdkVersion 16
targetSdkVersion 28
multiDexEnabled true
}
dexOptions {
jumboMode true
}
// Proguard configuration
buildTypes {
release {
//minifyEnabled true will turn proguard ON
minifyEnabled true
//proguardFiles let you add your own proguard rules ('proguard-project.txt') in this case, as its already created by gdx-setup
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-project.txt'
}
}

compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
productFlavors {
}
lintOptions {
abortOnError false
}
}

task importPuzzles(type: Exec) {
// TODO
}

task run(type: Exec) {
def path
def localProperties = project.file("../local.properties")
if (localProperties.exists()) {
Properties properties = new Properties()
localProperties.withInputStream { instr ->
properties.load(instr)
}
def sdkDir = properties.getProperty('sdk.dir')
if (sdkDir) {
path = sdkDir
} else {
path = "$System.env.ANDROID_HOME"
}
} else {
path = "$System.env.ANDROID_HOME"
}

def adb = path + "/platform-tools/adb"
commandLine "$adb", 'shell', 'am', 'start', '-n', 'com.myapp.id/com.myapp.id.AndroidLauncher'
}

dependencies {
implementation project(":android_common")
api 'com.android.support:multidex:1.0.3'
implementation "com.badlogicgames.gdx:gdx-backend-android:1.9.9-SNAPSHOT"
implementation "com.badlogicgames.gdx:gdx-freetype:1.9.9-SNAPSHOT"
implementation "com.android.billingclient:billing:dp-1"
implementation "com.google.firebase:firebase-core:16.0.5"
implementation "com.google.firebase:firebase-ads:17.0.0"
implementation 'com.crashlytics.sdk.android:crashlytics:2.9.5'

implementation fileTree(include: ['*.jar'], dir: 'libs')
}

// ADD THIS AT THE BOTTOM
apply plugin: 'com.google.gms.google-services'


:android_instant_feature



apply plugin: "com.android.feature"

android {
// baseFeature true
buildToolsVersion "28.0.2"
compileSdkVersion 28
sourceSets {
main {
manifest.srcFile 'AndroidManifest.xml'
java.srcDirs = ['src']
aidl.srcDirs = ['src']
renderscript.srcDirs = ['src']
res.srcDirs = ["${project(':android_common').projectDir}/res"]
assets.srcDirs = ['assets']
jniLibs.srcDirs = ['libs']
}
}
defaultConfig {
versionCode 4031
versionName "4.1.2.1i"
minSdkVersion 16
targetSdkVersion 28
multiDexEnabled true
}

dexOptions {
jumboMode true
}

// Proguard configuration
buildTypes {
release {
//minifyEnabled true will turn proguard ON
// minifyEnabled true
//proguardFiles let you add your own proguard rules ('proguard-project.txt') in this case, as its already created by gdx-setup
// proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-project.txt'
}
debug {}
}


compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
productFlavors {
}
lintOptions {
abortOnError false
}
}

task run(type: Exec) {
def path
def localProperties = project.file("../local.properties")
if (localProperties.exists()) {
Properties properties = new Properties()
localProperties.withInputStream { instr ->
properties.load(instr)
}
def sdkDir = properties.getProperty('sdk.dir')
if (sdkDir) {
path = sdkDir
} else {
path = "$System.env.ANDROID_HOME"
}
} else {
path = "$System.env.ANDROID_HOME"
}

def adb = path + "/platform-tools/adb"
commandLine "$adb", 'shell', 'am', 'start', '-n', 'com.myapp.id/com.myapp.id.AndroidLauncher'
}

dependencies {
implementation project(":android_common")
api 'com.android.support:multidex:1.0.3'
implementation "com.badlogicgames.gdx:gdx-backend-android:1.9.9-SNAPSHOT"
implementation "com.badlogicgames.gdx:gdx-freetype:1.9.9-SNAPSHOT"
implementation "com.google.firebase:firebase-core:16.0.5"
implementation 'com.google.android.gms:play-services-instantapps:16.0.1'

implementation fileTree(dir: 'libs', include: ['*.jar'])
}

// ADD THIS AT THE BOTTOM
apply plugin: 'com.google.gms.google-services'


Finally, this is the structure of my project. The most relevant part as it's android related is the one on the top. Below I just show how it's related to the core module.



enter image description here



This is a libGDX game and I'm working with IntelliJ Idea, though this is not relevant since I'm getting these errors with ./gradlew build in the command line.





EDIT: I downgraded firebase-core from 16.0.5 to 16.0.4 as suggested by TWL and it worked, so I think it's an acceptable workaround, at least while the firebase guys release a firebase-core 16.0.6 or so actually compatible with firebase-ads 17.0.0. The problem seems to be effectively that firebase-ads 17.0.0 relies on a older version of the library that's causing the error.



Look at these dependencies outputs:



This is what I get with firebase-core 16.0.4:



$ ./gradlew android_common:dependencies | grep measurement-base
<-------------> 0% EXECUTING [0s]
> :android_common:dependencies
| | | +--- com.google.android.gms:play-services-measurement-base:16.0.3
| | | | +--- com.google.android.gms:play-services-measurement-base:16.0.3
| | +--- com.google.android.gms:play-services-measurement-base:16.0.3
| +--- com.google.android.gms:play-services-measurement-base:16.0.3
| | | --- com.google.android.gms:play-services-measurement-base:16.0.3
| | | +--- com.google.android.gms:play-services-measurement-base:16.0.3
| | | | +--- com.google.android.gms:play-services-measurement-base:16.0.3
| | +--- com.google.android.gms:play-services-measurement-base:16.0.3
| +--- com.google.android.gms:play-services-measurement-base:16.0.3
| | | --- com.google.android.gms:play-services-measurement-base:16.0.3
| | | +--- com.google.android.gms:play-services-measurement-base:16.0.3
| | | | +--- com.google.android.gms:play-services-measurement-base:16.0.3
| | +--- com.google.android.gms:play-services-measurement-base:16.0.3
| +--- com.google.android.gms:play-services-measurement-base:16.0.3


... (and so on, all 16.0.3 straight forward)



And this for firebase-core 16.0.5:



$ ./gradlew android_common:dependencies | grep measurement-base
<-------------> 0% EXECUTING [1s]
> :android_common:dependencies > Resolve dependencies of :android_common:releaseUnitTestRuntimeClasspath
| | | +--- com.google.android.gms:play-services-measurement-base:[16.0.4] -> 16.0.4
| | | | +--- com.google.android.gms:play-services-measurement-base:[16.0.4] -> 16.0.4 (*)
| | +--- com.google.android.gms:play-services-measurement-base:[16.0.4] -> 16.0.4 (*)
| +--- com.google.android.gms:play-services-measurement-base:[16.0.4] -> 16.0.4 (*)
| | | --- com.google.android.gms:play-services-measurement-base:16.0.3 -> 16.0.4 (*)
| | | +--- com.google.android.gms:play-services-measurement-base:[16.0.4] -> 16.0.4
| | | | +--- com.google.android.gms:play-services-measurement-base:[16.0.4] -> 16.0.4 (*)
| | +--- com.google.android.gms:play-services-measurement-base:[16.0.4] -> 16.0.4 (*)
| +--- com.google.android.gms:play-services-measurement-base:[16.0.4] -> 16.0.4 (*)
| | | --- com.google.android.gms:play-services-measurement-base:16.0.3 -> 16.0.4 (*)
| | | +--- com.google.android.gms:play-services-measurement-base:[16.0.4] -> 16.0.4
| | | | +--- com.google.android.gms:play-services-measurement-base:[16.0.4] -> 16.0.4 (*)
| | +--- com.google.android.gms:play-services-measurement-base:[16.0.4] -> 16.0.4 (*)
| +--- com.google.android.gms:play-services-measurement-base:[16.0.4] -> 16.0.4 (*)
| | | --- com.google.android.gms:play-services-measurement-base:16.0.3 -> 16.0.4 (*)
| | | +--- com.google.android.gms:play-services-measurement-base:[16.0.4] -> 16.0.4
| | | | +--- com.google.android.gms:play-services-measurement-base:[16.0.4] -> 16.0.4 (*)
| | +--- com.google.android.gms:play-services-measurement-base:[16.0.4] -> 16.0.4 (*)
| +--- com.google.android.gms:play-services-measurement-base:[16.0.4] -> 16.0.4 (*)
| | | --- com.google.android.gms:play-services-measurement-base:16.0.3 -> 16.0.4 (*)
| | | +--- com.google.android.gms:play-services-measurement-base:[16.0.4] -> 16.0.4
| | | | +--- com.google.android.gms:play-services-measurement-base:[16.0.4] -> 16.0.4 (*)
| | +--- com.google.android.gms:play-services-measurement-base:[16.0.4] -> 16.0.4 (*)
| +--- com.google.android.gms:play-services-measurement-base:[16.0.4] -> 16.0.4 (*)
| | | --- com.google.android.gms:play-services-measurement-base:16.0.3 -> 16.0.4 (*)
| | | +--- com.google.android.gms:play-services-measurement-base:[16.0.4] -> 16.0.4
| | | | +--- com.google.android.gms:play-services-measurement-base:[16.0.4] -> 16.0.4 (*)
| | +--- com.google.android.gms:play-services-measurement-base:[16.0.4] -> 16.0.4 (*)
| +--- com.google.android.gms:play-services-measurement-base:[16.0.4] -> 16.0.4 (*)
| | | --- com.google.android.gms:play-services-measurement-base:16.0.3 -> 16.0.4 (*)
| | | +--- com.google.android.gms:play-services-measurement-base:[16.0.4] -> 16.0.4
| | | | +--- com.google.android.gms:play-services-measurement-base:[16.0.4] -> 16.0.4 (*)
| | +--- com.google.android.gms:play-services-measurement-base:[16.0.4] -> 16.0.4 (*)
| +--- com.google.android.gms:play-services-measurement-base:[16.0.4] -> 16.0.4 (*)
| | | --- com.google.android.gms:play-services-measurement-base:16.0.3 -> 16.0.4 (*)
| | | +--- com.google.android.gms:play-services-measurement-base:[16.0.4] -> 16.0.4
| | | | +--- com.google.android.gms:play-services-measurement-base:[16.0.4] -> 16.0.4 (*)
| | +--- com.google.android.gms:play-services-measurement-base:[16.0.4] -> 16.0.4 (*)
| +--- com.google.android.gms:play-services-measurement-base:[16.0.4] -> 16.0.4 (*)
| | | --- com.google.android.gms:play-services-measurement-base:16.0.3 -> 16.0.4 (*)
| | | +--- com.google.android.gms:play-services-measurement-base:[16.0.4] -> 16.0.4
| | | | +--- com.google.android.gms:play-services-measurement-base:[16.0.4] -> 16.0.4 (*)
| | +--- com.google.android.gms:play-services-measurement-base:[16.0.4] -> 16.0.4 (*)
| +--- com.google.android.gms:play-services-measurement-base:[16.0.4] -> 16.0.4 (*)
| | | --- com.google.android.gms:play-services-measurement-base:16.0.3 -> 16.0.4 (*)
| | | +--- com.google.android.gms:play-services-measurement-base:[16.0.4] -> 16.0.4
| | | | +--- com.google.android.gms:play-services-measurement-base:[16.0.4] -> 16.0.4 (*)
| | +--- com.google.android.gms:play-services-measurement-base:[16.0.4] -> 16.0.4 (*)
| +--- com.google.android.gms:play-services-measurement-base:[16.0.4] -> 16.0.4 (*)
| | | --- com.google.android.gms:play-services-measurement-base:16.0.3 -> 16.0.4 (*)
| | | +--- com.google.android.gms:play-services-measurement-base:[16.0.4] -> 16.0.4
| | | | +--- com.google.android.gms:play-services-measurement-base:[16.0.4] -> 16.0.4 (*)
| | +--- com.google.android.gms:play-services-measurement-base:[16.0.4] -> 16.0.4 (*)
| +--- com.google.android.gms:play-services-measurement-base:[16.0.4] -> 16.0.4 (*)
| | | --- com.google.android.gms:play-services-measurement-base:16.0.3 -> 16.0.4 (*)
| | | +--- com.google.android.gms:play-services-measurement-base:[16.0.4] -> 16.0.4
| | | | +--- com.google.android.gms:play-services-measurement-base:[16.0.4] -> 16.0.4 (*)
| | +--- com.google.android.gms:play-services-measurement-base:[16.0.4] -> 16.0.4 (*)
| +--- com.google.android.gms:play-services-measurement-base:[16.0.4] -> 16.0.4 (*)
| | | --- com.google.android.gms:play-services-measurement-base:16.0.3 -> 16.0.4 (*)
| | | +--- com.google.android.gms:play-services-measurement-base:[16.0.4] -> 16.0.4
| | | | +--- com.google.android.gms:play-services-measurement-base:[16.0.4] -> 16.0.4 (*)
| | +--- com.google.android.gms:play-services-measurement-base:[16.0.4] -> 16.0.4 (*)
| +--- com.google.android.gms:play-services-measurement-base:[16.0.4] -> 16.0.4 (*)
| | | --- com.google.android.gms:play-services-measurement-base:16.0.3 -> 16.0.4 (*)
| | | +--- com.google.android.gms:play-services-measurement-base:[16.0.4] -> 16.0.4
| | | | +--- com.google.android.gms:play-services-measurement-base:[16.0.4] -> 16.0.4 (*)
| | +--- com.google.android.gms:play-services-measurement-base:[16.0.4] -> 16.0.4 (*)
| +--- com.google.android.gms:play-services-measurement-base:[16.0.4] -> 16.0.4 (*)
| | | --- com.google.android.gms:play-services-measurement-base:16.0.3 -> 16.0.4 (*)
| | | +--- com.google.android.gms:play-services-measurement-base:[16.0.4] -> 16.0.4
| | | | +--- com.google.android.gms:play-services-measurement-base:[16.0.4] -> 16.0.4 (*)
| | +--- com.google.android.gms:play-services-measurement-base:[16.0.4] -> 16.0.4 (*)


As you see, there are some entries like "com.google.android.gms:play-services-measurement-base:16.0.3 -> 16.0.4 (*)" that, despite I'm not proficient on interpreting these outputs, I think are the cause of the issue.










share|improve this question















I have an app that builds just fine, but starts failing as soon as I try to update some Gradle dependencies, whereas the main suspect is firebase.



This is the error I'm getting:




Caused by:
com.android.builder.multidex.D8MainDexList$MainDexListException:
com.android.tools.r8.errors.CompilationError: Program type already
present: com.google.android.gms.internal.measurement.zzdz




And this is the git diff for my project, showing the differences in the Gradle files:



diff --git a/android/build.gradle b/android/build.gradle
index 9f63f745..08fda2eb 100644
--- a/android/build.gradle
+++ b/android/build.gradle
@@ -81,8 +81,8 @@ dependencies {
implementation "com.badlogicgames.gdx:gdx-backend-android:$gdxVersion"
implementation "com.badlogicgames.gdx:gdx-freetype:$gdxVersion"
implementation "com.android.billingclient:billing:$playBillingLibVersion"
- implementation "com.google.firebase:firebase-core:16.0.3"
- implementation "com.google.firebase:firebase-ads:15.0.1"
+ implementation "com.google.firebase:firebase-core:16.0.5"
+ implementation "com.google.firebase:firebase-ads:17.0.0"
implementation 'com.crashlytics.sdk.android:crashlytics:2.9.5'

implementation fileTree(include: ['*.jar'], dir: 'libs')
diff --git a/android_common/build.gradle b/android_common/build.gradle
index f8224509..3a5d45e1 100644
--- a/android_common/build.gradle
+++ b/android_common/build.gradle
@@ -19,7 +19,7 @@ android {
androidTest.setRoot('tests')
}
defaultConfig {
- minSdkVersion 15
+ minSdkVersion 16
targetSdkVersion 28
versionCode 1
versionName "1.0"
@@ -65,8 +65,8 @@ dependencies {
natives "com.badlogicgames.gdx:gdx-freetype-platform:$gdxVersion:natives-x86"
natives "com.badlogicgames.gdx:gdx-freetype-platform:$gdxVersion:natives-x86_64"
implementation "com.android.billingclient:billing:$playBillingLibVersion"
- implementation "com.google.firebase:firebase-core:16.0.3"
- implementation "com.google.firebase:firebase-ads:15.0.1"
+ implementation "com.google.firebase:firebase-core:16.0.5"
+ implementation "com.google.firebase:firebase-ads:17.0.0"

implementation fileTree(include: ['*.jar'], dir: 'libs')
testImplementation 'junit:junit:4.12'
diff --git a/android_instant_feature/build.gradle b/android_instant_feature/build.gradle
index 30431c11..17c4ef27 100644
--- a/android_instant_feature/build.gradle
+++ b/android_instant_feature/build.gradle
@@ -18,7 +18,7 @@ android {
defaultConfig {
versionCode 4031
versionName "4.1.2.1i"
- minSdkVersion 15
+ minSdkVersion 16
targetSdkVersion 28
multiDexEnabled true
}
@@ -77,8 +77,8 @@ dependencies {
api 'com.android.support:multidex:1.0.3'
implementation "com.badlogicgames.gdx:gdx-backend-android:$gdxVersion"
implementation "com.badlogicgames.gdx:gdx-freetype:$gdxVersion"
- implementation "com.google.firebase:firebase-core:16.0.3"
- implementation 'com.google.android.gms:play-services-instantapps:16.0.0'
+ implementation "com.google.firebase:firebase-core:16.0.5"
+ implementation 'com.google.android.gms:play-services-instantapps:16.0.1'

implementation fileTree(dir: 'libs', include: ['*.jar'])
}
diff --git a/core/build.gradle b/core/build.gradle
index dd2640cf..5694a1da 100644
--- a/core/build.gradle
+++ b/core/build.gradle
@@ -15,7 +15,7 @@ dependencies {
compile group: 'commons-io', name: 'commons-io', version: '2.6'
// https://mvnrepository.com/artifact/commons-codec/commons-codec
compile group: 'commons-codec', name: 'commons-codec', version: '1.11'
- compile 'com.google.code.gson:gson:2.8.2'
+ compile 'com.google.code.gson:gson:2.8.5'
compile group: 'org.apache.commons', name: 'commons-text', version: '1.2'
compile group: 'org.apache.commons', name: 'commons-collections4', version: '4.1'
compile group: 'org.jetbrains', name: 'annotations', version: '16.0.1'
@@ -23,7 +23,7 @@ dependencies {
implementation "com.badlogicgames.gdx:gdx-freetype:$gdxVersion"

testCompile 'junit:junit:4.12'
- testCompile 'org.mockito:mockito-core:2.7.22'
+ testCompile 'org.mockito:mockito-core:2.8.9'
testCompile group: 'org.powermock', name: 'powermock-api-mockito2', version: '1.7.3'
testCompile group: 'org.powermock', name: 'powermock-module-junit4', version: '1.7.3'
}


Please, note that some of these changes like the minSDKVersion can be discarded as the source of the error. It seems most likely it is related to firebase. Why? Well, among other things there are other questions in Stackoverflow in which that's the case, however the solution proposed in all of these is to update firebase dependencies to last version, but updating firebase dependencies to last version is what it seems to be causing the problem in my project! With the old versions it just builds fine.



These are the contents of the Gradle scripts involved (I have replaced the actual applicationId with 'com.myapp.id')



:core



apply plugin: "java"

targetCompatibility = 1.8
sourceCompatibility = 1.8
[compileJava, compileTestJava]*.options*.encoding = 'UTF-8'

sourceSets.main.java.srcDirs = ["src/main"]
sourceSets.test.java.srcDirs = ["src/test"]

dependencies {
compile 'commons-io:commons-io:2.6'
compile 'commons-codec:commons-codec:1.11'
compile 'com.google.code.gson:gson:2.8.5'
compile 'org.apache.commons:commons-text:1.2'
compile 'org.apache.commons:commons-collections4:4.1'
compile 'org.jetbrains:annotations:16.0.1'
compile "com.badlogicgames.gdx:gdx:1.9.9-SNAPSHOT"
compile "com.badlogicgames.gdx:gdx-freetype:1.9.9-SNAPSHOT"

testCompile 'junit:junit:4.12'
testCompile 'org.mockito:mockito-core:2.8.9'
testCompile 'org.powermock:powermock-api-mockito2:1.7.3'
testCompile 'org.powermock:powermock-module-junit4:1.7.3'
}


repositories {
mavenCentral()
}

jar {
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
}


:android_common



apply plugin: "com.android.feature"

configurations { natives }

android {
baseFeature true
compileSdkVersion 28
sourceSets {
main {
manifest.srcFile 'AndroidManifest.xml'
java.srcDirs = ['src']
aidl.srcDirs = ['src']
renderscript.srcDirs = ['src']
res.srcDirs = ['res']
assets.srcDirs = ['assets']
jniLibs.srcDirs = ['libs']
}

androidTest.setRoot('tests')
}
defaultConfig {
minSdkVersion 16
targetSdkVersion 28
versionCode 1
versionName "1.0"

testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
sourceSets {
all {
manifest.srcFile "AndroidManifest.xml"
}
}
multiDexEnabled true
}
buildTypes {
release {
setMinifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
buildToolsVersion '28.0.2'
lintOptions {
abortOnError false
}
dexOptions {
jumboMode true
}
}

dependencies {
application project(':android')
feature project(':android_instant_feature')
api project(':core')
api 'com.android.support:multidex:1.0.3'
implementation "com.badlogicgames.gdx:gdx-backend-android:1.9.9-SNAPSHOT"
natives "com.badlogicgames.gdx:gdx-platform:1.9.9-SNAPSHOT:natives-armeabi"
natives "com.badlogicgames.gdx:gdx-platform:1.9.9-SNAPSHOT:natives-armeabi-v7a"
natives "com.badlogicgames.gdx:gdx-platform:1.9.9-SNAPSHOT:natives-arm64-v8a"
natives "com.badlogicgames.gdx:gdx-platform:1.9.9-SNAPSHOT:natives-x86"
natives "com.badlogicgames.gdx:gdx-platform:1.9.9-SNAPSHOT:natives-x86_64"
implementation "com.badlogicgames.gdx:gdx-freetype:1.9.9-SNAPSHOT"
natives "com.badlogicgames.gdx:gdx-freetype-platform:1.9.9-SNAPSHOT:natives-armeabi"
natives "com.badlogicgames.gdx:gdx-freetype-platform:1.9.9-SNAPSHOT:natives-armeabi-v7a"
natives "com.badlogicgames.gdx:gdx-freetype-platform:1.9.9-SNAPSHOT:natives-arm64-v8a"
natives "com.badlogicgames.gdx:gdx-freetype-platform:1.9.9-SNAPSHOT:natives-x86"
natives "com.badlogicgames.gdx:gdx-freetype-platform:1.9.9-SNAPSHOT:natives-x86_64"
implementation "com.android.billingclient:billing:dp-1"
implementation "com.google.firebase:firebase-core:16.0.5"
implementation "com.google.firebase:firebase-ads:17.0.0"

implementation fileTree(include: ['*.jar'], dir: 'libs')
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
implementation 'com.google.guava:guava:24.0-android'
}

task copyAndroidNatives() {
file("libs/armeabi/").mkdirs();
file("libs/armeabi-v7a/").mkdirs();
file("libs/arm64-v8a/").mkdirs();
file("libs/x86_64/").mkdirs();
file("libs/x86/").mkdirs();

configurations.natives.files.each { jar ->
def outputDir = null
if (jar.name.endsWith("natives-arm64-v8a.jar")) outputDir = file("libs/arm64-v8a")
if (jar.name.endsWith("natives-armeabi-v7a.jar")) outputDir = file("libs/armeabi-v7a")
if (jar.name.endsWith("natives-armeabi.jar")) outputDir = file("libs/armeabi")
if (jar.name.endsWith("natives-x86_64.jar")) outputDir = file("libs/x86_64")
if (jar.name.endsWith("natives-x86.jar")) outputDir = file("libs/x86")
if (outputDir != null) {
copy {
from zipTree(jar)
into outputDir
include "*.so"
}
}
}
}


:android



apply plugin: "com.android.application"
apply plugin: 'io.fabric' // Needed by crashlytics. DO NOT REMOVE.

android {
buildToolsVersion "28.0.2"
compileSdkVersion 28
sourceSets {
main {
manifest.srcFile 'AndroidManifest.xml'
java.srcDirs = ['src']
aidl.srcDirs = ['src']
renderscript.srcDirs = ['src']
res.srcDirs = ["${project(':android_common').projectDir}/res"]
assets.srcDirs = ['assets']
jniLibs.srcDirs = ['libs']
}

androidTest.setRoot('tests')
}
defaultConfig {
applicationId "com.myapp.id"
versionCode 4032
versionName "4.1.2.1"
minSdkVersion 16
targetSdkVersion 28
multiDexEnabled true
}
dexOptions {
jumboMode true
}
// Proguard configuration
buildTypes {
release {
//minifyEnabled true will turn proguard ON
minifyEnabled true
//proguardFiles let you add your own proguard rules ('proguard-project.txt') in this case, as its already created by gdx-setup
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-project.txt'
}
}

compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
productFlavors {
}
lintOptions {
abortOnError false
}
}

task importPuzzles(type: Exec) {
// TODO
}

task run(type: Exec) {
def path
def localProperties = project.file("../local.properties")
if (localProperties.exists()) {
Properties properties = new Properties()
localProperties.withInputStream { instr ->
properties.load(instr)
}
def sdkDir = properties.getProperty('sdk.dir')
if (sdkDir) {
path = sdkDir
} else {
path = "$System.env.ANDROID_HOME"
}
} else {
path = "$System.env.ANDROID_HOME"
}

def adb = path + "/platform-tools/adb"
commandLine "$adb", 'shell', 'am', 'start', '-n', 'com.myapp.id/com.myapp.id.AndroidLauncher'
}

dependencies {
implementation project(":android_common")
api 'com.android.support:multidex:1.0.3'
implementation "com.badlogicgames.gdx:gdx-backend-android:1.9.9-SNAPSHOT"
implementation "com.badlogicgames.gdx:gdx-freetype:1.9.9-SNAPSHOT"
implementation "com.android.billingclient:billing:dp-1"
implementation "com.google.firebase:firebase-core:16.0.5"
implementation "com.google.firebase:firebase-ads:17.0.0"
implementation 'com.crashlytics.sdk.android:crashlytics:2.9.5'

implementation fileTree(include: ['*.jar'], dir: 'libs')
}

// ADD THIS AT THE BOTTOM
apply plugin: 'com.google.gms.google-services'


:android_instant_feature



apply plugin: "com.android.feature"

android {
// baseFeature true
buildToolsVersion "28.0.2"
compileSdkVersion 28
sourceSets {
main {
manifest.srcFile 'AndroidManifest.xml'
java.srcDirs = ['src']
aidl.srcDirs = ['src']
renderscript.srcDirs = ['src']
res.srcDirs = ["${project(':android_common').projectDir}/res"]
assets.srcDirs = ['assets']
jniLibs.srcDirs = ['libs']
}
}
defaultConfig {
versionCode 4031
versionName "4.1.2.1i"
minSdkVersion 16
targetSdkVersion 28
multiDexEnabled true
}

dexOptions {
jumboMode true
}

// Proguard configuration
buildTypes {
release {
//minifyEnabled true will turn proguard ON
// minifyEnabled true
//proguardFiles let you add your own proguard rules ('proguard-project.txt') in this case, as its already created by gdx-setup
// proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-project.txt'
}
debug {}
}


compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
productFlavors {
}
lintOptions {
abortOnError false
}
}

task run(type: Exec) {
def path
def localProperties = project.file("../local.properties")
if (localProperties.exists()) {
Properties properties = new Properties()
localProperties.withInputStream { instr ->
properties.load(instr)
}
def sdkDir = properties.getProperty('sdk.dir')
if (sdkDir) {
path = sdkDir
} else {
path = "$System.env.ANDROID_HOME"
}
} else {
path = "$System.env.ANDROID_HOME"
}

def adb = path + "/platform-tools/adb"
commandLine "$adb", 'shell', 'am', 'start', '-n', 'com.myapp.id/com.myapp.id.AndroidLauncher'
}

dependencies {
implementation project(":android_common")
api 'com.android.support:multidex:1.0.3'
implementation "com.badlogicgames.gdx:gdx-backend-android:1.9.9-SNAPSHOT"
implementation "com.badlogicgames.gdx:gdx-freetype:1.9.9-SNAPSHOT"
implementation "com.google.firebase:firebase-core:16.0.5"
implementation 'com.google.android.gms:play-services-instantapps:16.0.1'

implementation fileTree(dir: 'libs', include: ['*.jar'])
}

// ADD THIS AT THE BOTTOM
apply plugin: 'com.google.gms.google-services'


Finally, this is the structure of my project. The most relevant part as it's android related is the one on the top. Below I just show how it's related to the core module.



enter image description here



This is a libGDX game and I'm working with IntelliJ Idea, though this is not relevant since I'm getting these errors with ./gradlew build in the command line.





EDIT: I downgraded firebase-core from 16.0.5 to 16.0.4 as suggested by TWL and it worked, so I think it's an acceptable workaround, at least while the firebase guys release a firebase-core 16.0.6 or so actually compatible with firebase-ads 17.0.0. The problem seems to be effectively that firebase-ads 17.0.0 relies on a older version of the library that's causing the error.



Look at these dependencies outputs:



This is what I get with firebase-core 16.0.4:



$ ./gradlew android_common:dependencies | grep measurement-base
<-------------> 0% EXECUTING [0s]
> :android_common:dependencies
| | | +--- com.google.android.gms:play-services-measurement-base:16.0.3
| | | | +--- com.google.android.gms:play-services-measurement-base:16.0.3
| | +--- com.google.android.gms:play-services-measurement-base:16.0.3
| +--- com.google.android.gms:play-services-measurement-base:16.0.3
| | | --- com.google.android.gms:play-services-measurement-base:16.0.3
| | | +--- com.google.android.gms:play-services-measurement-base:16.0.3
| | | | +--- com.google.android.gms:play-services-measurement-base:16.0.3
| | +--- com.google.android.gms:play-services-measurement-base:16.0.3
| +--- com.google.android.gms:play-services-measurement-base:16.0.3
| | | --- com.google.android.gms:play-services-measurement-base:16.0.3
| | | +--- com.google.android.gms:play-services-measurement-base:16.0.3
| | | | +--- com.google.android.gms:play-services-measurement-base:16.0.3
| | +--- com.google.android.gms:play-services-measurement-base:16.0.3
| +--- com.google.android.gms:play-services-measurement-base:16.0.3


... (and so on, all 16.0.3 straight forward)



And this for firebase-core 16.0.5:



$ ./gradlew android_common:dependencies | grep measurement-base
<-------------> 0% EXECUTING [1s]
> :android_common:dependencies > Resolve dependencies of :android_common:releaseUnitTestRuntimeClasspath
| | | +--- com.google.android.gms:play-services-measurement-base:[16.0.4] -> 16.0.4
| | | | +--- com.google.android.gms:play-services-measurement-base:[16.0.4] -> 16.0.4 (*)
| | +--- com.google.android.gms:play-services-measurement-base:[16.0.4] -> 16.0.4 (*)
| +--- com.google.android.gms:play-services-measurement-base:[16.0.4] -> 16.0.4 (*)
| | | --- com.google.android.gms:play-services-measurement-base:16.0.3 -> 16.0.4 (*)
| | | +--- com.google.android.gms:play-services-measurement-base:[16.0.4] -> 16.0.4
| | | | +--- com.google.android.gms:play-services-measurement-base:[16.0.4] -> 16.0.4 (*)
| | +--- com.google.android.gms:play-services-measurement-base:[16.0.4] -> 16.0.4 (*)
| +--- com.google.android.gms:play-services-measurement-base:[16.0.4] -> 16.0.4 (*)
| | | --- com.google.android.gms:play-services-measurement-base:16.0.3 -> 16.0.4 (*)
| | | +--- com.google.android.gms:play-services-measurement-base:[16.0.4] -> 16.0.4
| | | | +--- com.google.android.gms:play-services-measurement-base:[16.0.4] -> 16.0.4 (*)
| | +--- com.google.android.gms:play-services-measurement-base:[16.0.4] -> 16.0.4 (*)
| +--- com.google.android.gms:play-services-measurement-base:[16.0.4] -> 16.0.4 (*)
| | | --- com.google.android.gms:play-services-measurement-base:16.0.3 -> 16.0.4 (*)
| | | +--- com.google.android.gms:play-services-measurement-base:[16.0.4] -> 16.0.4
| | | | +--- com.google.android.gms:play-services-measurement-base:[16.0.4] -> 16.0.4 (*)
| | +--- com.google.android.gms:play-services-measurement-base:[16.0.4] -> 16.0.4 (*)
| +--- com.google.android.gms:play-services-measurement-base:[16.0.4] -> 16.0.4 (*)
| | | --- com.google.android.gms:play-services-measurement-base:16.0.3 -> 16.0.4 (*)
| | | +--- com.google.android.gms:play-services-measurement-base:[16.0.4] -> 16.0.4
| | | | +--- com.google.android.gms:play-services-measurement-base:[16.0.4] -> 16.0.4 (*)
| | +--- com.google.android.gms:play-services-measurement-base:[16.0.4] -> 16.0.4 (*)
| +--- com.google.android.gms:play-services-measurement-base:[16.0.4] -> 16.0.4 (*)
| | | --- com.google.android.gms:play-services-measurement-base:16.0.3 -> 16.0.4 (*)
| | | +--- com.google.android.gms:play-services-measurement-base:[16.0.4] -> 16.0.4
| | | | +--- com.google.android.gms:play-services-measurement-base:[16.0.4] -> 16.0.4 (*)
| | +--- com.google.android.gms:play-services-measurement-base:[16.0.4] -> 16.0.4 (*)
| +--- com.google.android.gms:play-services-measurement-base:[16.0.4] -> 16.0.4 (*)
| | | --- com.google.android.gms:play-services-measurement-base:16.0.3 -> 16.0.4 (*)
| | | +--- com.google.android.gms:play-services-measurement-base:[16.0.4] -> 16.0.4
| | | | +--- com.google.android.gms:play-services-measurement-base:[16.0.4] -> 16.0.4 (*)
| | +--- com.google.android.gms:play-services-measurement-base:[16.0.4] -> 16.0.4 (*)
| +--- com.google.android.gms:play-services-measurement-base:[16.0.4] -> 16.0.4 (*)
| | | --- com.google.android.gms:play-services-measurement-base:16.0.3 -> 16.0.4 (*)
| | | +--- com.google.android.gms:play-services-measurement-base:[16.0.4] -> 16.0.4
| | | | +--- com.google.android.gms:play-services-measurement-base:[16.0.4] -> 16.0.4 (*)
| | +--- com.google.android.gms:play-services-measurement-base:[16.0.4] -> 16.0.4 (*)
| +--- com.google.android.gms:play-services-measurement-base:[16.0.4] -> 16.0.4 (*)
| | | --- com.google.android.gms:play-services-measurement-base:16.0.3 -> 16.0.4 (*)
| | | +--- com.google.android.gms:play-services-measurement-base:[16.0.4] -> 16.0.4
| | | | +--- com.google.android.gms:play-services-measurement-base:[16.0.4] -> 16.0.4 (*)
| | +--- com.google.android.gms:play-services-measurement-base:[16.0.4] -> 16.0.4 (*)
| +--- com.google.android.gms:play-services-measurement-base:[16.0.4] -> 16.0.4 (*)
| | | --- com.google.android.gms:play-services-measurement-base:16.0.3 -> 16.0.4 (*)
| | | +--- com.google.android.gms:play-services-measurement-base:[16.0.4] -> 16.0.4
| | | | +--- com.google.android.gms:play-services-measurement-base:[16.0.4] -> 16.0.4 (*)
| | +--- com.google.android.gms:play-services-measurement-base:[16.0.4] -> 16.0.4 (*)
| +--- com.google.android.gms:play-services-measurement-base:[16.0.4] -> 16.0.4 (*)
| | | --- com.google.android.gms:play-services-measurement-base:16.0.3 -> 16.0.4 (*)
| | | +--- com.google.android.gms:play-services-measurement-base:[16.0.4] -> 16.0.4
| | | | +--- com.google.android.gms:play-services-measurement-base:[16.0.4] -> 16.0.4 (*)
| | +--- com.google.android.gms:play-services-measurement-base:[16.0.4] -> 16.0.4 (*)
| +--- com.google.android.gms:play-services-measurement-base:[16.0.4] -> 16.0.4 (*)
| | | --- com.google.android.gms:play-services-measurement-base:16.0.3 -> 16.0.4 (*)
| | | +--- com.google.android.gms:play-services-measurement-base:[16.0.4] -> 16.0.4
| | | | +--- com.google.android.gms:play-services-measurement-base:[16.0.4] -> 16.0.4 (*)
| | +--- com.google.android.gms:play-services-measurement-base:[16.0.4] -> 16.0.4 (*)
| +--- com.google.android.gms:play-services-measurement-base:[16.0.4] -> 16.0.4 (*)
| | | --- com.google.android.gms:play-services-measurement-base:16.0.3 -> 16.0.4 (*)
| | | +--- com.google.android.gms:play-services-measurement-base:[16.0.4] -> 16.0.4
| | | | +--- com.google.android.gms:play-services-measurement-base:[16.0.4] -> 16.0.4 (*)
| | +--- com.google.android.gms:play-services-measurement-base:[16.0.4] -> 16.0.4 (*)
| +--- com.google.android.gms:play-services-measurement-base:[16.0.4] -> 16.0.4 (*)
| | | --- com.google.android.gms:play-services-measurement-base:16.0.3 -> 16.0.4 (*)
| | | +--- com.google.android.gms:play-services-measurement-base:[16.0.4] -> 16.0.4
| | | | +--- com.google.android.gms:play-services-measurement-base:[16.0.4] -> 16.0.4 (*)
| | +--- com.google.android.gms:play-services-measurement-base:[16.0.4] -> 16.0.4 (*)
| +--- com.google.android.gms:play-services-measurement-base:[16.0.4] -> 16.0.4 (*)
| | | --- com.google.android.gms:play-services-measurement-base:16.0.3 -> 16.0.4 (*)
| | | +--- com.google.android.gms:play-services-measurement-base:[16.0.4] -> 16.0.4
| | | | +--- com.google.android.gms:play-services-measurement-base:[16.0.4] -> 16.0.4 (*)
| | +--- com.google.android.gms:play-services-measurement-base:[16.0.4] -> 16.0.4 (*)


As you see, there are some entries like "com.google.android.gms:play-services-measurement-base:16.0.3 -> 16.0.4 (*)" that, despite I'm not proficient on interpreting these outputs, I think are the cause of the issue.







java android firebase gradle






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 8 at 19:55

























asked Nov 8 at 13:18









Fran Marzoa

2,09612137




2,09612137












  • Comments are not for extended discussion; this conversation has been moved to chat.
    – Samuel Liew
    Nov 9 at 8:30


















  • Comments are not for extended discussion; this conversation has been moved to chat.
    – Samuel Liew
    Nov 9 at 8:30
















Comments are not for extended discussion; this conversation has been moved to chat.
– Samuel Liew
Nov 9 at 8:30




Comments are not for extended discussion; this conversation has been moved to chat.
– Samuel Liew
Nov 9 at 8:30












1 Answer
1






active

oldest

votes

















up vote
1
down vote



accepted










Alright, since all comments have been moved to chat and my temporary workaround was there too, here it is then:



Your error message brought my searching to com.android.tools.r8.errors.CompilationError: Program type already present: androidx.annotation.AnimRes




Caused by:
com.android.builder.multidex.D8MainDexList$MainDexListException:
com.android.tools.r8.errors.CompilationError: Program type already
present: ___




That error suggests there is a duplicate dependency somewhere that is running off two different versions. Then the goal is to run ./gradlew app:dependencies to produce a tree/list of the dependencies to look for com.google.android.gms.internal.measurement.zzdz. The problem is that this is obfuscated and an internal private package, so it won't be directly found in the list, but the keyword measurement is a hint.



This led me to notice that core and ads have something similar: play-services-measurement-api:[16.0.3] -> 16.0.3 (*) and play-services-measurement-sdk-api:16.0.2. With testing, I found two workarounds:




  1. downgrade com.google.firebase:firebase-core:16.0.5 to 16.0.4

  2. add exclude group: 'com.google.android.gms', module: 'play-services-measurement-sdk-api' to the ads dependency


First option is probably safer to do, since a re-run of ./gradlew app:dependencies showed that play-services-measurement-api and play-services-measurement-sdk-api were both now 16.0.2.



And I'm sure Google/Firebase is aware of this since I did just find another mention of it at https://issuetracker.google.com/issues/119213680 The translation is: The error is duplicate of class zzdz, the transition of the existence status of zzdz class is as follows. So beware that play-services-measurement-sdk-api can run into issues with other Firebase/GMS libraries. There should be an upcoming fix to update it.



*Note that even switching to "com.google.firebase:firebase-ads:17.1.0" will still cause this error.






share|improve this answer





















    Your Answer






    StackExchange.ifUsing("editor", function () {
    StackExchange.using("externalEditor", function () {
    StackExchange.using("snippets", function () {
    StackExchange.snippets.init();
    });
    });
    }, "code-snippets");

    StackExchange.ready(function() {
    var channelOptions = {
    tags: "".split(" "),
    id: "1"
    };
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function() {
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled) {
    StackExchange.using("snippets", function() {
    createEditor();
    });
    }
    else {
    createEditor();
    }
    });

    function createEditor() {
    StackExchange.prepareEditor({
    heartbeatType: 'answer',
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader: {
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    },
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    });


    }
    });














     

    draft saved


    draft discarded


















    StackExchange.ready(
    function () {
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53208575%2fbuild-errors-after-updating-gradle-dependencies-suspect-1-is-firebase%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown

























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes








    up vote
    1
    down vote



    accepted










    Alright, since all comments have been moved to chat and my temporary workaround was there too, here it is then:



    Your error message brought my searching to com.android.tools.r8.errors.CompilationError: Program type already present: androidx.annotation.AnimRes




    Caused by:
    com.android.builder.multidex.D8MainDexList$MainDexListException:
    com.android.tools.r8.errors.CompilationError: Program type already
    present: ___




    That error suggests there is a duplicate dependency somewhere that is running off two different versions. Then the goal is to run ./gradlew app:dependencies to produce a tree/list of the dependencies to look for com.google.android.gms.internal.measurement.zzdz. The problem is that this is obfuscated and an internal private package, so it won't be directly found in the list, but the keyword measurement is a hint.



    This led me to notice that core and ads have something similar: play-services-measurement-api:[16.0.3] -> 16.0.3 (*) and play-services-measurement-sdk-api:16.0.2. With testing, I found two workarounds:




    1. downgrade com.google.firebase:firebase-core:16.0.5 to 16.0.4

    2. add exclude group: 'com.google.android.gms', module: 'play-services-measurement-sdk-api' to the ads dependency


    First option is probably safer to do, since a re-run of ./gradlew app:dependencies showed that play-services-measurement-api and play-services-measurement-sdk-api were both now 16.0.2.



    And I'm sure Google/Firebase is aware of this since I did just find another mention of it at https://issuetracker.google.com/issues/119213680 The translation is: The error is duplicate of class zzdz, the transition of the existence status of zzdz class is as follows. So beware that play-services-measurement-sdk-api can run into issues with other Firebase/GMS libraries. There should be an upcoming fix to update it.



    *Note that even switching to "com.google.firebase:firebase-ads:17.1.0" will still cause this error.






    share|improve this answer

























      up vote
      1
      down vote



      accepted










      Alright, since all comments have been moved to chat and my temporary workaround was there too, here it is then:



      Your error message brought my searching to com.android.tools.r8.errors.CompilationError: Program type already present: androidx.annotation.AnimRes




      Caused by:
      com.android.builder.multidex.D8MainDexList$MainDexListException:
      com.android.tools.r8.errors.CompilationError: Program type already
      present: ___




      That error suggests there is a duplicate dependency somewhere that is running off two different versions. Then the goal is to run ./gradlew app:dependencies to produce a tree/list of the dependencies to look for com.google.android.gms.internal.measurement.zzdz. The problem is that this is obfuscated and an internal private package, so it won't be directly found in the list, but the keyword measurement is a hint.



      This led me to notice that core and ads have something similar: play-services-measurement-api:[16.0.3] -> 16.0.3 (*) and play-services-measurement-sdk-api:16.0.2. With testing, I found two workarounds:




      1. downgrade com.google.firebase:firebase-core:16.0.5 to 16.0.4

      2. add exclude group: 'com.google.android.gms', module: 'play-services-measurement-sdk-api' to the ads dependency


      First option is probably safer to do, since a re-run of ./gradlew app:dependencies showed that play-services-measurement-api and play-services-measurement-sdk-api were both now 16.0.2.



      And I'm sure Google/Firebase is aware of this since I did just find another mention of it at https://issuetracker.google.com/issues/119213680 The translation is: The error is duplicate of class zzdz, the transition of the existence status of zzdz class is as follows. So beware that play-services-measurement-sdk-api can run into issues with other Firebase/GMS libraries. There should be an upcoming fix to update it.



      *Note that even switching to "com.google.firebase:firebase-ads:17.1.0" will still cause this error.






      share|improve this answer























        up vote
        1
        down vote



        accepted







        up vote
        1
        down vote



        accepted






        Alright, since all comments have been moved to chat and my temporary workaround was there too, here it is then:



        Your error message brought my searching to com.android.tools.r8.errors.CompilationError: Program type already present: androidx.annotation.AnimRes




        Caused by:
        com.android.builder.multidex.D8MainDexList$MainDexListException:
        com.android.tools.r8.errors.CompilationError: Program type already
        present: ___




        That error suggests there is a duplicate dependency somewhere that is running off two different versions. Then the goal is to run ./gradlew app:dependencies to produce a tree/list of the dependencies to look for com.google.android.gms.internal.measurement.zzdz. The problem is that this is obfuscated and an internal private package, so it won't be directly found in the list, but the keyword measurement is a hint.



        This led me to notice that core and ads have something similar: play-services-measurement-api:[16.0.3] -> 16.0.3 (*) and play-services-measurement-sdk-api:16.0.2. With testing, I found two workarounds:




        1. downgrade com.google.firebase:firebase-core:16.0.5 to 16.0.4

        2. add exclude group: 'com.google.android.gms', module: 'play-services-measurement-sdk-api' to the ads dependency


        First option is probably safer to do, since a re-run of ./gradlew app:dependencies showed that play-services-measurement-api and play-services-measurement-sdk-api were both now 16.0.2.



        And I'm sure Google/Firebase is aware of this since I did just find another mention of it at https://issuetracker.google.com/issues/119213680 The translation is: The error is duplicate of class zzdz, the transition of the existence status of zzdz class is as follows. So beware that play-services-measurement-sdk-api can run into issues with other Firebase/GMS libraries. There should be an upcoming fix to update it.



        *Note that even switching to "com.google.firebase:firebase-ads:17.1.0" will still cause this error.






        share|improve this answer












        Alright, since all comments have been moved to chat and my temporary workaround was there too, here it is then:



        Your error message brought my searching to com.android.tools.r8.errors.CompilationError: Program type already present: androidx.annotation.AnimRes




        Caused by:
        com.android.builder.multidex.D8MainDexList$MainDexListException:
        com.android.tools.r8.errors.CompilationError: Program type already
        present: ___




        That error suggests there is a duplicate dependency somewhere that is running off two different versions. Then the goal is to run ./gradlew app:dependencies to produce a tree/list of the dependencies to look for com.google.android.gms.internal.measurement.zzdz. The problem is that this is obfuscated and an internal private package, so it won't be directly found in the list, but the keyword measurement is a hint.



        This led me to notice that core and ads have something similar: play-services-measurement-api:[16.0.3] -> 16.0.3 (*) and play-services-measurement-sdk-api:16.0.2. With testing, I found two workarounds:




        1. downgrade com.google.firebase:firebase-core:16.0.5 to 16.0.4

        2. add exclude group: 'com.google.android.gms', module: 'play-services-measurement-sdk-api' to the ads dependency


        First option is probably safer to do, since a re-run of ./gradlew app:dependencies showed that play-services-measurement-api and play-services-measurement-sdk-api were both now 16.0.2.



        And I'm sure Google/Firebase is aware of this since I did just find another mention of it at https://issuetracker.google.com/issues/119213680 The translation is: The error is duplicate of class zzdz, the transition of the existence status of zzdz class is as follows. So beware that play-services-measurement-sdk-api can run into issues with other Firebase/GMS libraries. There should be an upcoming fix to update it.



        *Note that even switching to "com.google.firebase:firebase-ads:17.1.0" will still cause this error.







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Nov 9 at 17:56









        TWL

        1,616619




        1,616619






























             

            draft saved


            draft discarded



















































             


            draft saved


            draft discarded














            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53208575%2fbuild-errors-after-updating-gradle-dependencies-suspect-1-is-firebase%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            Schultheiß

            Verwaltungsgliederung Dänemarks

            Liste der Kulturdenkmale in Wilsdruff