简体   繁体   中英

Program type already present: com.google.android.gms.internal.measurement.zzu when adding firebase-perf library

As soon as I add latest version of firebase-perf library it stops compiling with the following error:

Caused by: com.android.tools.r8.utils.AbortException:
Error: Program type already present: com.google.android.gms.internal.measurement.zzu

Note: I am already using latest version of all the available dependencies from android and Firebase.

My project level build.gradle :

buildscript {
    repositories {
        google()
        jcenter()
        maven { url 'https://maven.fabric.io/public' }
        maven {
            url 'https://maven.google.com/'
            name 'Google'
        }
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.2.1'
        classpath 'io.fabric.tools:gradle:1.+'
        classpath 'com.google.gms:google-services:4.2.0'
        classpath 'com.google.firebase:firebase-plugins:1.1.5'
    }
}
allprojects {
    repositories {
        google()
        jcenter()
        mavenCentral()
        maven { url 'https://maven.fabric.io/public' }
        maven { url 'http://dl.bintray.com/amulyakhare/maven' }
        maven { url "https://jitpack.io" }
        maven {
            url 'https://github.com/WickeDev/stetho-realm/raw/master/maven-repo'
        }
    }
}

My app level build.gradle :

apply plugin: 'com.android.application'
apply plugin: 'com.google.firebase.firebase-perf'
apply plugin: 'io.fabric'
apply plugin: 'realm-android'

task wrapper(type: Wrapper) {
    gradleVersion = '4.1'
}

buildscript {
    repositories {
        mavenCentral()
        jcenter()
    }

    dependencies {
        classpath "io.realm:realm-gradle-plugin:5.4.1"
    }


}

subprojects {
    project.configurations.all {
        resolutionStrategy.eachDependency { details ->
            if (details.requested.group == 'com.android.support'
                    && !details.requested.name.contains('multidex')) {
                details.useVersion "26.1.0"
            }
        }
    }
}


android {
    compileSdkVersion 28
    buildToolsVersion '28.0.3'

        configurations.all {
            resolutionStrategy.force 'com.google.code.findbugs:jsr305:1.3.9'
        }
    }

    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }

    defaultConfig {
        minSdkVersion 15
        targetSdkVersion 28
        versionCode 180
        versionName "2.11.8"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
        multiDexEnabled true
        resConfigs "en"
    }

    dexOptions {
        javaMaxHeapSize "4G"
        maxProcessCount 4
    }
    buildTypes {
        debug {
            minifyEnabled false
        }
        release {
            minifyEnabled true
            shrinkResources true
            proguardFile getDefaultProguardFile('proguard-android.txt')
            fileTree(dir: 'proguard-rules', include: '*.pro').each { file -> proguardFile file }
        }
    }
    aaptOptions {
        cruncherEnabled false
    }
    packagingOptions {
        exclude 'META-INF/DEPENDENCIES'
        exclude 'META-INF/NOTICE'
        exclude 'META-INF/LICENSE'
        exclude 'META-INF/LICENSE.txt'
        exclude 'META-INF/NOTICE.txt'
        exclude 'META-INF/services/javax.annotation.processing.Processor'
        exclude 'META-INF/ECLIPSE_.SF'
        exclude 'META-INF/ECLIPSE_.RSA'
    }
}


dependencies {

    // https://mvnrepository.com/artifact/commons-codec/commons-codec
    implementation group: 'commons-codec', name: 'commons-codec', version: '1.10'

    // Support library
    implementation('com.android.support:appcompat-v7:28.0.0') {
        exclude group: 'com.android.support', module: 'support-annotations'
    }
    // Play services
    implementation('com.google.android.gms:play-services-analytics:15.0.2') {
        exclude group: 'com.android.support'
        // exclude group: 'com.google.android.gms', module: 'play-services-basement'
        // exclude group: 'com.google.android.gms', module: 'play-services-measurement-base'
    }
    implementation 'com.google.android.gms:play-services-auth:16.0.1';
    // Square
    implementation("com.squareup.okhttp3:okhttp:3.12.0")
    implementation('com.squareup.okhttp3:logging-interceptor:3.12.0') {
        transitive = false
    }
    implementation('com.squareup.retrofit2:retrofit:2.5.0') {
        // exclude Retrofit’s OkHttp peer-dependency module and define your own module import
        exclude module: 'okhttp'
    }
    implementation 'com.squareup.retrofit2:adapter-rxjava:2.5.0'
    implementation 'com.squareup.retrofit2:converter-gson:2.5.0'

    // UI/UX
    implementation('com.kogitune:pre-lollipop-activity-transition:1.3.0') {
        exclude group: 'com.android.support'
    }
    //App Intro
    implementation('com.github.paolorotolo:appintro:4.1.0@aar') {
        exclude group: 'com.android.support'
        transitive = true
    }
    // Tools

    implementation('io.branch.sdk.android:library:2.+') {
        exclude group: 'com.android.support'
    }
    implementation('com.crashlytics.sdk.android:crashlytics:2.5.2@aar') {
        transitive = true
    }
    // Test
    androidTestImplementation('com.android.support.test.espresso:espresso-contrib:2.2') {
        // Necessary to avoid version conflicts

        exclude module: 'recyclerview-v7'
    }
    // Razorpay
    implementation 'com.razorpay:checkout:1.5.1'

    //Reactive Location
    implementation 'pl.charmas.android:android-reactive-location:1.0@aar'
    implementation 'com.android.support:multidex:1.0.3'
    implementation 'com.android.support:recyclerview-v7:28.0.0'
    implementation 'com.android.support:animated-vector-drawable:28.0.0'
    implementation 'com.android.support:customtabs:28.0.0'
    implementation 'com.android.support:exifinterface:28.0.0'
    implementation 'com.android.support:support-v4:28.0.0'
    implementation 'com.android.support:support-media-compat:28.0.0'
    implementation 'com.android.support:cardview-v7:28.0.0'
    implementation 'com.android.support:design:28.0.0'
    implementation 'com.android.support:support-annotations:28.0.0'
    implementation 'com.google.android.gms:play-services-location:16.0.0'
    implementation 'com.google.android.gms:play-services-maps:16.0.0'
    implementation 'com.google.android.libraries.places:places-compat:1.0.0'
    implementation 'com.squareup.okio:okio:1.15.0'
    implementation 'com.google.code.gson:gson:2.8.5'
    dependencies {
        implementation 'com.jakewharton:butterknife:8.8.1'
        annotationProcessor 'com.jakewharton:butterknife-compiler:8.8.1'
    }
    implementation 'com.jakewharton.timber:timber:4.1.2'
    implementation 'com.squareup.picasso:picasso:2.5.2'
    implementation 'com.jakewharton.picasso:picasso2-okhttp3-downloader:1.1.0'
    implementation 'com.balysv:material-ripple:1.0.2'
    implementation 'com.amulyakhare:com.amulyakhare.textdrawable:1.0.1'
    implementation 'com.timehop.stickyheadersrecyclerview:library:0.4.3@aar'
    implementation 'me.zhanghai.android.materialprogressbar:library:1.1.4@aar'
    implementation 'com.wdullaer:materialdatetimepicker:2.3.0@aar'
    implementation 'com.orhanobut:logger:1.8'
    implementation 'com.facebook.conceal:conceal:1.0.1@aar'
    implementation 'io.reactivex:rxjava:1.3.0'
    implementation 'io.reactivex:rxandroid:1.2.1@aar'
    implementation 'com.f2prateek.rx.preferences:rx-preferences:1.0.2@aar'
    implementation 'com.tbruyelle.rxpermissions:rxpermissions:0.9.4@aar'
    dependencies {
        implementation 'com.google.dagger:dagger:2.13'
        annotationProcessor 'com.google.dagger:dagger-compiler:2.13'
    }
    dependencies {
        implementation 'com.github.matthiasrobbers:shortbread:1.0.2'
        annotationProcessor 'com.github.matthiasrobbers:shortbread-compiler:1.0.2'
    }
    implementation 'org.jbundle.util.osgi.wrapped:org.jbundle.util.osgi.wrapped.org.apache.http.client:4.1.2'
    implementation 'com.google.firebase:firebase-messaging:17.3.4'
    implementation 'com.google.firebase:firebase-core:16.0.6'
    implementation('com.google.firebase:firebase-perf:16.2.3')    <------------- Compile issue happens when I add this
    implementation 'com.facebook.stetho:stetho:1.5.0'
    implementation 'com.facebook.stetho:stetho-okhttp3:1.5.0'
    // implementation 'com.uphyca:stetho_realm:2.3.0'
    implementation 'com.android.support.constraint:constraint-layout:1.1.3'

    testImplementation 'org.robolectric:robolectric:3.0'
    testImplementation 'junit:junit:4.12'
    testImplementation 'org.mockito:mockito-core:1.10.19'
    androidTestImplementation 'com.jakewharton:butterknife:8.8.1'
    androidTestImplementation 'com.android.support:support-annotations:28.0.0'
    androidTestImplementation 'com.android.support.test:runner:1.0.2'
    androidTestImplementation 'com.android.support.test:rules:1.0.2'
    androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
    androidTestImplementation 'com.android.support.test.espresso:espresso-intents:3.0.2'
    androidTestImplementation 'com.android.support.test.espresso:espresso-idling-resource:3.0.2'
    androidTestImplementation 'com.android.support.test.uiautomator:uiautomator-v18:2.1.3'
    androidTestImplementation 'com.android.support:support-v4:28.0.0'

    implementation 'com.elyeproj.libraries:loaderviewlibrary:1.4.1'

    // Animations
    implementation 'com.android.support:support-compat:28.0.0'
    implementation 'com.daimajia.easing:library:2.0@aar'
    implementation 'com.daimajia.androidanimations:library:2.3@aar'

    // Pusher
    implementation 'com.pusher:pusher-java-client:1.6.0'

    // Custom crash activity
    implementation 'cat.ereza:customactivityoncrash:2.2.0'

    // Snackbar
    implementation 'com.github.matecode:Snacky:1.0.3'

    // Progress bar
    implementation 'com.github.castorflex.smoothprogressbar:library:1.3.0'

    implementation 'com.github.chrisbanes:PhotoView:2.0.0'

//    debugImplementation 'com.squareup.leakcanary:leakcanary-android:1.6.2'
//    releaseImplementation 'com.squareup.leakcanary:leakcanary-android-no-op:1.6.2'
    implementation 'org.conscrypt:conscrypt-android:1.4.1'

    // Facebook connection class to classify network bandwidth
    implementation 'com.facebook.network.connectionclass:connectionclass:1.0.1';
}

apply from: 'tasks.gradle'

apply plugin: 'com.google.gms.google-services'

com.google.gms.googleservices.GoogleServicesPlugin.config.disableVersionCheck = true

I solved this problem by removing play-services-analytics from the app level build.gradle .

implementation('com.google.android.gms:play-services-analytics:15.0.2') {
    exclude group: 'com.android.support'

}

It seems like firebase analytics and google analytics can't coexist.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM