我正在尝试将依赖项更新到最新版本。我会在提示时安装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突出显示了这一行:
答案 0 :(得分:2)
已修复play-services-ads:17.1.1
和firebase-core:16.0.5
。