程序类型已存在:com.google.android.gms.internal.measurement.zzdz

3

我正在尝试将依赖项更新到最新版本。我安装了Android Studio提示的新版本。但是当启动应用程序时,出现以下错误:

Error: Program type already present: com.google.android.gms.internal.measurement.zzdz

我的 build.gradle(模块):

apply plugin: 'com.android.application'
apply plugin: 'com.google.gms.google-services'
apply plugin: 'io.fabric'

android {
    compileSdkVersion 27
    buildToolsVersion '28.0.3'
    defaultConfig {
        applicationId '***'
        minSdkVersion 16
        targetSdkVersion 27
        testInstrumentationRunner 'android.support.test.runner.AndroidJUnitRunner'
        vectorDrawables.useSupportLibrary true
        renderscriptTargetApi 27
        renderscriptSupportModeEnabled true
    }
    lintOptions {
        checkReleaseBuilds false
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    androidTestImplementation('com.android.support.test.espresso:espresso-core:2.2.2', {
        exclude group: 'com.android.support', module: 'support-annotations'
    })
    implementation 'com.android.support:appcompat-v7:27.1.1'
    implementation 'com.android.support:customtabs:27.1.1'
    implementation 'com.android.support:design:27.1.1'
    implementation 'com.android.support:cardview-v7:27.1.1'
    implementation 'com.android.support.constraint:constraint-layout:1.1.3'
    implementation 'com.android.support:support-v4:27.1.1'
    implementation 'com.android.billingclient:billing:1.1'
    implementation 'com.google.zxing:core:3.3.0'
    implementation 'com.google.android.gms:play-services-ads:17.1.0'
    implementation 'com.google.firebase:firebase-core:16.0.5'
    implementation 'com.crashlytics.sdk.android:crashlytics:2.9.6'
    implementation 'com.facebook.android:facebook-login:4.35.0'
    implementation 'com.journeyapps:zxing-android-embedded:3.2.0@aar'
    testImplementation 'junit:junit:4.12'
}

我的 build.gradle(项目):

buildscript {
    repositories {
        jcenter()
        maven {
            url "https://maven.google.com"
        }
        maven {
            url 'https://maven.fabric.io/public'
        }
        google()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.2.1'
        classpath 'com.google.gms:google-services:4.2.0'
        classpath 'io.fabric.tools:gradle:1.25.4'
    }
}

allprojects {
    repositories {
        jcenter()
        maven {
            url "https://maven.google.com"
        }
        google()
    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}

如何避免这个错误?有哪些依赖项冲突?

更新:

如果我试图更改firebase-core的版本为

implementation 'com.google.firebase: firebase-core: 16.0.4'

在这种情况下,应用程序运行时没有出现错误,但是Android Studio会突出显示此行代码:

enter image description here


2
高亮显示没问题,Android Studio会提示依赖项不是最新版本。请等待Google发布16.0.6或更高版本。 - Onix
1个回答

2

使用 play-services-ads:17.1.1firebase-core:16.0.5 进行修复。


1
太棒了!17.1.1版本已经出现。在写这篇文章的时候,最新版本是17.1.0。现在如果我按照你所写的进行替换,一切都能正常工作。谢谢你。 - Vergiliy
哇,谢谢。这真的救了我的一天。我不明白为什么谷歌不能正确更新它的文档。真的很难弄清楚... - Panther

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接