Adding Firebase In-App Messaging dependency gives DexArchiveMergerException
Asked Answered
H

2

7

I was testing the Firebase In-App Messaging feature, added the dependency

implementation 'com.google.firebase:firebase-inappmessaging-display:17.0.0'

But android studio throws DexArchiveMergerException. I have multi dexing enabled as shown in the below build.gradle.

Here is my build.gradle(app)

apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
apply plugin: 'com.google.firebase.firebase-perf'
apply plugin: 'io.fabric'
android {
    compileSdkVersion 27
    buildToolsVersion '27.0.3'

    dexOptions {
        keepRuntimeAnnotatedClasses false
    }

    defaultConfig {
        applicationId "np.com.aawaz.csitentrance"
        minSdkVersion 16
        targetSdkVersion 25
        multiDexEnabled true
        versionCode 80
        versionName "3.1.3"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation 'com.android.support:design:27.1.1'
    implementation 'com.android.support:appcompat-v7:27.1.1'
    implementation 'com.android.support:recyclerview-v7:27.1.1'
    implementation 'com.android.support:cardview-v7:27.1.1'
    implementation 'com.android.support:support-v4:27.1.1'
    implementation 'com.android.support.constraint:constraint-layout:1.1.2'
    implementation 'com.nineoldandroids:library:2.4.0'
    implementation 'com.facebook.android:facebook-android-sdk:4.34.0'
    implementation 'com.google.android.gms:play-services-auth:16.0.0'
    implementation 'com.afollestad.material-dialogs:core:0.9.6.0'
    implementation 'com.squareup.okhttp3:okhttp:3.10.0'
    implementation 'com.squareup.picasso:picasso:2.5.2'
    implementation 'com.daimajia.easing:library:2.0@aar'
    implementation 'com.daimajia.slider:library:1.1.5@aar'
    implementation 'com.daimajia.androidanimations:library:2.2@aar'
    implementation 'de.hdodenhof:circleimageview:2.2.0'
    implementation 'com.github.medyo:fancybuttons:1.8.4'
    implementation 'gun0912.ted:tedpermission:2.2.0'
    implementation 'com.amulyakhare:com.amulyakhare.textdrawable:1.0.1'
    implementation 'com.google.code.gson:gson:2.8.4'
    implementation 'com.android.support:multidex:1.0.3'

    implementation 'com.crashlytics.sdk.android:crashlytics:2.9.4'

    implementation 'com.google.firebase:firebase-core:16.0.1'
    implementation 'com.google.firebase:firebase-messaging:17.3.0'
    implementation 'com.google.firebase:firebase-auth:16.0.3'
    implementation 'com.google.firebase:firebase-database:16.0.1'
    implementation 'com.google.firebase:firebase-firestore:17.1.0'
    implementation 'com.google.firebase:firebase-storage:16.0.1'
    implementation 'com.google.firebase:firebase-perf:16.1.0'
    implementation 'com.google.firebase:firebase-appindexing:16.0.1'
    implementation 'com.google.firebase:firebase-inappmessaging-display:17.0.0'
    implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
}
apply plugin: 'com.google.gms.google-services'
repositories {
    mavenCentral()
}

build.gradle(project)

buildscript {
    ext.kotlin_version = '1.2.50'
    repositories {
        mavenCentral()
        maven { url "https://jitpack.io" }
        jcenter()
        google()
        maven {
            url 'https://maven.google.com/'
        }
        maven { url 'http://dl.bintray.com/amulyakhare/maven' }
        maven { url 'https://maven.fabric.io/public' }
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.1.3'
        classpath 'com.google.gms:google-services:4.0.1'
        classpath 'com.google.firebase:firebase-plugins:1.1.5'
        classpath 'io.fabric.tools:gradle:1.25.4'
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
    }
}

allprojects {
    repositories {
        mavenCentral()
        maven { url "https://jitpack.io" }
        jcenter()
        google()
        maven {
            url 'https://maven.google.com/'
        }
        maven { url 'http://dl.bintray.com/amulyakhare/maven' }
        maven { url 'https://maven.fabric.io/public' }
    }
}

Here are the errors that I am getting:

Program type already present: com.google.a.a.a.a.zza
Message{kind=ERROR, text=Program type already present: com.google.a.a.a.a.zza, sources=[Unknown source file], tool name=Optional.of(D8)}

and

org.gradle.initialization.ReportedException: org.gradle.internal.exceptions.LocationAwareException: Execution failed for task ':app:transformDexArchiveWithDexMergerForDebug'.

and

java.lang.RuntimeException: com.android.builder.dexing.DexArchiveMergerException: Error while merging dex archives: /Users/muskan/AndroidStudioProjects/CSIT_Entrance/app/build/intermediates/transforms/dexBuilder/debug/0, /Users/muskan/AndroidStudioProjects/CSIT_Entrance/app/build/intermediates/transforms/dexBuilder/debug/1, /Users/muskan/AndroidStudioProjects/CSIT_Entrance/app/build/intermediates/transforms/dexBuilder/debug/2, /Users/muskan/AndroidStudioProjects/CSIT_Entrance/app/build/intermediates/transforms/dexBuilder/debug/3, /Users/muskan/AndroidStudioProjects/CSIT_Entrance/app/build/intermediates/transforms/dexBuilder/debug/5, /Users/muskan/AndroidStudioProjects/CSIT_Entrance/app/build/intermediates/transforms/dexBuilder/debug/6, /Users/muskan/AndroidStudioProjects/CSIT_Entrance/app/build/intermediates/transforms/dexBuilder/debug/7, /Users/muskan/AndroidStudioProjects/CSIT_Entrance/app/build/intermediates/transforms/dexBuilder/debug/8, /Users/muskan/AndroidStudioProjects/CSIT_Entrance/app/build/intermediates/transforms/dexBuilder/debug/9, /Users/muskan/AndroidStudioProjects/CSIT_Entrance/app/build/intermediates/transforms/dexBuilder/debug/11, /Users/muskan/AndroidStudioProjects/CSIT_Entrance/app/build/intermediates/transforms/dexBuilder/debug/12, /Users/muskan/AndroidStudioProjects/CSIT_Entrance/app/build/intermediates/transforms/dexBuilder/debug/13, /Users/muskan/AndroidStudioProjects/CSIT_Entrance/app/build/intermediates/transforms/dexBuilder/debug/14, /Users/muskan/AndroidStudioProjects/CSIT_Entrance/app/build/intermediates/transforms/dexBuilder/debug/15, /Users/muskan/AndroidStudioProjects/CSIT_Entrance/app/build/intermediates/transforms/dexBuilder/debug/16, /Users/muskan/AndroidStudioProjects/CSIT_Entrance/app/build/intermediates/transforms/dexBuilder/debug/17, /Users/muskan/AndroidStudioProjects/CSIT_Entrance/app/build/intermediates/transforms/dexBuilder/debug/18, /Users/muskan/AndroidStudioProjects/CSIT_Entrance/app/build/intermediates/transforms/dexBuilder/debug/19, /Users/muskan/AndroidStudioProjects/CSIT_Entrance/app/build/intermediates/transforms/dexBuilder/debug/20, /Users/muskan/AndroidStudioProjects/CSIT_Entrance/app/build/intermediates/transforms/dexBuilder/debug/21, /Users/muskan/AndroidStudioProjects/CSIT_Entrance/app/build/intermediates/transforms/dexBuilder/debug/22, /Users/muskan/AndroidStudioProjects/CSIT_Entrance/app/build/intermediates/transforms/dexBuilder/debug/23, /Users/muskan/AndroidStudioProjects/CSIT_Entrance/app/build/intermediates/transforms/dexBuilder/debug/24, /Users/muskan/AndroidStudioProjects/CSIT_Entrance/app/build/intermediates/transforms/dexBuilder/debug/25, /Users/muskan/AndroidStudioProjects/CSIT_Entrance/app/build/intermediates/transforms/dexBuilder/debug/27, /Users/muskan/AndroidStudioProjects/CSIT_Entrance/app/build/intermediates/transforms/dexBuilder/debug/28, /Users/muskan/AndroidStudioProjects/CSIT_Entrance/app/build/intermediates/transforms/dexBuilder/debug/29, /Users/muskan/AndroidStudioProjects/CSIT_Entrance/app/build/intermediates/transforms/dexBuilder/debug/30, /Users/muskan/AndroidStudioProjects/CSIT_Entrance/app/build/intermediates/transforms/dexBuilder/debug/31, /Users/muskan/AndroidStudioProjects/CSIT_Entrance/app/build/intermediates/transforms/dexBuilder/debug/32, /Users/muskan/AndroidStudioProjects/CSIT_Entrance/app/build/intermediates/transforms/dexBuilder/debug/33, /Users/muskan/AndroidStudioProjects/CSIT_Entrance/app/build/intermediates/transforms/dexBuilder/debug/34, /Users/muskan/AndroidStudioProjects/CSIT_Entrance/app/build/intermediates/transforms/dexBuilder/debug/35, /Users/muskan/AndroidStudioProjects/CSIT_Entrance/app/build/intermediates/transforms/dexBuilder/debug/36, /Users/muskan/AndroidStudioProjects/CSIT_Entrance/app/build/intermediates/transforms/dexBuilder/debug/37, /Users/muskan/AndroidStudioProjects/CSIT_Entrance/app/build/intermediates/transforms/dexBuilder/debug/38, /Users/muskan/AndroidStudioProjects/CSIT_Entrance/app/build/intermediates/transforms/dexBuilder/debug/39, /Users/muskan/AndroidStudioProjects/CSIT_Entrance/app/build/intermediates/transforms/dexBuilder/debug/40, /Users/muskan/AndroidStudioProjects/CSIT_Entrance/app/build/intermediates/transforms/dexBuilder/debug/41, /Users/muskan/AndroidStudioProjects/CSIT_Entrance/app/build/intermediates/transforms/dexBuilder/debug/42, /Users/muskan/AndroidStudioProjects/CSIT_Entrance/app/build/intermediates/transforms/dexBuilder/debug/44, /Users/muskan/AndroidStudioProjects/CSIT_Entrance/app/build/intermediates/transforms/dexBuilder/debug/45, /Users/muskan/AndroidStudioProjects/CSIT_Entrance/app/build/intermediates/transforms/dexBuilder/debug/46, /Users/muskan/AndroidStudioProjects/CSIT_Entrance/app/build/intermediates/transforms/dexBuilder/debug/47, /Users/muskan/AndroidStudioProjects/CSIT_Entrance/app/build/intermediates/transforms/dexBuilder/debug/48, /Users/muskan/AndroidStudioProjects/CSIT_Entrance/app/build/intermediates/transforms/dexBuilder/debug/49, /Users/muskan/AndroidStudioProjects/CSIT_Entrance/app/build/intermediates/transforms/dexBuilder/debug/50, /Users/muskan/AndroidStudioProjects/CSIT_Entrance/app/build/intermediates/transforms/dexBuilder/debug/51, /Users/muskan/AndroidStudioProjects/CSIT_Entrance/app/build/intermediates/transforms/dexBuilder/debug/52, /Users/muskan/AndroidStudioProjects/CSIT_Entrance/app/build/intermediates/transforms/dexBuilder/debug/53, /Users/muskan/AndroidStudioProjects/CSIT_Entrance/app/build/intermediates/transforms/dexBuilder/debug/54, /Users/muskan/AndroidStudioProjects/CSIT_Entrance/app/build/intermediates/transforms/dexBuilder/debug/55, /Users/muskan/AndroidStudioProjects/CSIT_Entrance/app/build/intermediates/transforms/dexBuilder/debug/56, /Users/muskan/AndroidStudioProjects/CSIT_Entrance/app/build/intermediates/transforms/dexBuilder/debug/57, /Users/muskan/AndroidStudioProjects/CSIT_Entrance/app/build/intermediates/transforms/dexBuilder/debug/58, /Users/muskan/AndroidStudioProjects/CSIT_Entrance/app/build/intermediates/transforms/dexBuilder/debug/59, /Users/muskan/AndroidStudioProjects/CSIT_Entrance/app/build/intermediates/transforms/dexBuilder/debug/60, /Users/muskan/AndroidStudioProjects/CSIT_Entrance/app/build/intermediates/transforms/dexBuilder/debug/61, /Users/muskan/AndroidStudioProjects/CSIT_Entrance/app/build/intermediates/transforms/dexBuilder/debug/62, /Users/muskan/AndroidStudioProjects/CSIT_Entrance/app/build/intermediates/transforms/dexBuilder/debug/63, /Users/muskan/AndroidStudioProjects/CSIT_Entrance/app/build/intermediates/transforms/dexBuilder/debug/64, /Users/muskan/AndroidStudioProjects/CSIT_Entrance/app/build/intermediates/transforms/dexBuilder/debug/65, /Users/muskan/AndroidStudioProjects/CSIT_Entrance/app/build/intermediates/transforms/dexBuilder/debug/67, /Users/muskan/AndroidStudioProjects/CSIT_Entrance/app/build/intermediates/transforms/dexBuilder/debug/68, /Users/muskan/AndroidStudioProjects/CSIT_Entrance/app/build/intermediates/transforms/dexBuilder/debug/69, /Users/muskan/AndroidStudioProjects/CSIT_Entrance/app/build/intermediates/transforms/dexBuilder/debug/70, /Users/muskan/AndroidStudioProjects/CSIT_Entrance/app/build/intermediates/transforms/dexBuilder/debug/71, /Users/muskan/AndroidStudioProjects/CSIT_Entrance/app/build/intermediates/transforms/dexBuilder/debug/72, /Users/muskan/AndroidStudioProjects/CSIT_Entrance/app/build/intermediates/transforms/dexBuilder/debug/73, /Users/muskan/AndroidStudioProjects/CSIT_Entrance/app/build/intermediates/transforms/dexBuilder/debug/74, /Users/muskan/AndroidStudioProjects/CSIT_Entrance/app/build/intermediates/transforms/dexBuilder/debug/75, /Users/muskan/AndroidStudioProjects/CSIT_Entrance/app/build/intermediates/transforms/dexBuilder/debug/76, /Users/muskan/AndroidStudioProjects/CSIT_Entrance/app/build/intermediates/transforms/dexBuilder/debug/78, /Users/muskan/AndroidStudioProjects/CSIT_Entrance/app/build/intermediates/transforms/dexBuilder/debug/79, /Users/muskan/AndroidStudioProjects/CSIT_Entrance/app/build/intermediates/transforms/dexBuilder/debug/80, /Users/muskan/AndroidStudioProjects/CSIT_Entrance/app/build/intermediates/transforms/dexBuilder/debug/81, /Users/muskan/AndroidStudioProjects/CSIT_Entrance/app/build/intermediates/transforms/dexBuilder/debug/82, /Users/muskan/AndroidStudioProjects/CSIT_Entrance/app/build/intermediates/transforms/dexBuilder/debug/83, /Users/muskan/AndroidStudioProjects/CSIT_Entrance/app/build/intermediates/transforms/dexBuilder/debug/84, /Users/muskan/AndroidStudioProjects/CSIT_Entrance/app/build/intermediates/transforms/dexBuilder/debug/86, /Users/muskan/AndroidStudioProjects/CSIT_Entrance/app/build/intermediates/transforms/dexBuilder/debug/87, /Users/muskan/AndroidStudioProjects/CSIT_Entrance/app/build/intermediates/transforms/dexBuilder/debug/88, /Users/muskan/AndroidStudioProjects/CSIT_Entrance/app/build/intermediates/transforms/dexBuilder/debug/89, /Users/muskan/AndroidStudioProjects/CSIT_Entrance/app/build/intermediates/transforms/dexBuilder/debug/90, /Users/muskan/AndroidStudioProjects/CSIT_Entrance/app/build/intermediates/transforms/dexBuilder/debug/91, /Users/muskan/AndroidStudioProjects/CSIT_Entrance/app/build/intermediates/transforms/dexBuilder/debug/94, /Users/muskan/AndroidStudioProjects/CSIT_Entrance/app/build/intermediates/transforms/dexBuilder/debug/95, /Users/muskan/AndroidStudioProjects/CSIT_Entrance/app/build/intermediates/transforms/dexBuilder/debug/96, /Users/muskan/AndroidStudioProjects/CSIT_Entrance/app/build/intermediates/transforms/dexBuilder/debug/97, /Users/muskan/AndroidStudioProjects/CSIT_Entrance/app/build/intermediates/transforms/dexBuilder/debug/98, /Users/muskan/AndroidStudioProjects/CSIT_Entrance/app/build/intermediates/transforms/dexBuilder/debug/99, /Users/muskan/AndroidStudioProjects/CSIT_Entrance/app/build/intermediates/transforms/dexBuilder/debug/100, /Users/muskan/AndroidStudioProjects/CSIT_Entrance/app/build/intermediates/transforms/dexBuilder/debug/105, /Users/muskan/AndroidStudioProjects/CSIT_Entrance/app/build/intermediates/transforms/dexBuilder/debug/106, /Users/muskan/AndroidStudioProjects/CSIT_Entrance/app/build/intermediates/transforms/dexBuilder/debug/107, /Users/muskan/AndroidStudioProjects/CSIT_Entrance/app/build/intermediates/transforms/dexBuilder/debug/108, /Users/muskan/AndroidStudioProjects/CSIT_Entrance/app/build/intermediates/transforms/dexBuilder/debug/109, /Users/muskan/AndroidStudioProjects/CSIT_Entrance/app/build/intermediates/transforms/dexBuilder/debug/110, /Users/muskan/AndroidStudioProjects/CSIT_Entrance/app/build/intermediates/transforms/dexBuilder/debug/111, /Users/muskan/AndroidStudioProjects/CSIT_Entrance/app/build/intermediates/transforms/dexBuilder/debug/112, /Users/muskan/AndroidStudioProjects/CSIT_Entrance/app/build/intermediates/transforms/dexBuilder/debug/120, /Users/muskan/AndroidStudioProjects/CSIT_Entrance/app/build/intermediates/transforms/dexBuilder/debug/121, /Users/muskan/AndroidStudioProjects/CSIT_Entrance/app/build/intermediates/transforms/dexBuilder/debug/122, /Users/muskan/AndroidStudioProjects/CSIT_Entrance/app/build/intermediates/transforms/dexBuilder/debug/123, /Users/muskan/AndroidStudioProjects/CSIT_Entrance/app/build/intermediates/transforms/dexBuilder/debug/124, /Users/muskan/AndroidStudioProjects/CSIT_Entrance/app/build/intermediates/transforms/dexBuilder/debug/125, /Users/muskan/AndroidStudioProjects/CSIT_Entrance/app/build/intermediates/transforms/dexBuilder/debug/126, /Users/muskan/AndroidStudioProjects/CSIT_Entrance/app/build/intermediates/transforms/dexBuilder/debug/127, /Users/muskan/AndroidStudioProjects/CSIT_Entrance/app/build/intermediates/transforms/dexBuilder/debug/128, /Users/muskan/AndroidStudioProjects/CSIT_Entrance/app/build/intermediates/transforms/dexBuilder/debug/129, /Users/muskan/AndroidStudioProjects/CSIT_Entrance/app/build/intermediates/transforms/dexBuilder/debug/136, /Users/muskan/AndroidStudioProjects/CSIT_Entrance/app/build/intermediates/transforms/dexBuilder/debug/137, /Users/muskan/AndroidStudioProjects/CSIT_Entrance/app/build/intermediates/transforms/dexBuilder/debug/138, /Users/muskan/AndroidStudioProjects/CSIT_Entrance/app/build/intermediates/transforms/dexBuilder/debug/139, /Users/muskan/AndroidStudioProjects/CSIT_Entrance/app/build/intermediates/transforms/dexBuilder/debug/140, /Users/muskan/AndroidStudioProjects/CSIT_Entrance/app/build/intermediates/transforms/dexBuilder/debug/141, /Users/muskan/AndroidStudioProjects/CSIT_Entrance/app/build/intermediates/transforms/dexBuilder/debug/142, /Users/muskan/AndroidStudioProjects/CSIT_Entrance/app/build/intermediates/transforms/dexBuilder/debug/143, /Users/muskan/AndroidStudioProjects/CSIT_Entrance/app/build/intermediates/transforms/dexBuilder/debug/144, /Users/muskan/AndroidStudioProjects/CSIT_Entrance/app/build/intermediates/transforms/dexBuilder/debug/145, /Users/muskan/AndroidStudioProjects/CSIT_Entrance/app/build/intermediates/transforms/dexBuilder/debug/146, /Users/muskan/AndroidStudioProjects/CSIT_Entrance/app/build/intermediates/transforms/dexBuilder/debug/147, /Users/muskan/AndroidStudioProjects/CSIT_Entrance/app/build/intermediates/transforms/dexBuilder/debug/148, /Users/muskan/AndroidStudioProjects/CSIT_Entrance/app/build/intermediates/transforms/dexBuilder/debug/149  
Heddie answered 16/8, 2018 at 17:8 Comment(5)
Typically, to help with problems like this we need to see both your project and app module build.gradle files. Please update your post to include them.Nekton
I am also getting the same error.Cesaro
@BobSnyder I have added both app and project level build.gradle files. Can you please help now.Heddie
Possible duplicate of InApp Messaging ErrorBisulfate
@RosárioPereiraFernandes I saw the question, its different coz I have implemented Mutidexing already but he hasn't.Heddie
M
4

Both firebase-firestore and firebase-inappmessaging-display contain com.google.a.a.a.a.zza that is why you get the following error:

Program type already present: com.google.a.a.a.a.zza

Removing implementation 'com.google.firebase:firebase-firestore:17.1.0' will fix the problem.

Edit:

This has been finally fixed after Firebase did an update

enter image description here

Now you are able to use firestore and In-AppMessaging in the same project

Mediative answered 17/8, 2018 at 7:54 Comment(10)
I am using Firestore in the project, removing the dependency gave me Unresolved reference: firestoreHeddie
@AawazGyawali oh okay, yes if u use firestore in your code then it won't work. I copied both of your gradle file and the problem is because this com.google.a.a.a.a.zza is in both dependencies, its why you get program present error developer.android.com/studio/build/…Mediative
So can you please tell me the solution for this?Jean
have you tried your project without firestore @sjmach? Did it work? Also not sure what the solution isMediative
@PeterHaddad It does work without Firestore, but that I do use Firestore for other purposes. Filing a bug with Firebase team.Jean
This got solved. I removed the firestore dependency and added the latest firebase other dependencies. Internally the firestore dependency was resolved and in app messaging is working now.Jean
@Jean can you elaborate bit more. I removed all the dependencies and re added the latest one. it's still the same.Heddie
@Aawaz, can you remove only firestore dependency and only add in app messaging display dependency to current dependencies list? Don't add latest versions just do above change, it will work.Jean
@Jean he can't remove firestore as he said in the first comment hereMediative
@AawazGyawali this should be fixed nowMediative
M
0
  1. Try to change targetSdkVersion to 27 and minSdkVersion 23

  2. clean

  3. rebuild

Mooned answered 17/8, 2018 at 1:56 Comment(1)
I cannot simply change minSdkVersion to 23 to fix this issue, I have lots of users on API below 23.Heddie

© 2022 - 2024 — McMap. All rights reserved.