gpt4 book ai didi

java - 如何修复 "Duplicate class com.google.android.gms.common.api.internal.zza"错误?

转载 作者:行者123 更新时间:2023-11-29 02:20:34 27 4
gpt4 key购买 nike

我已经将 Android Studio 更新到 3.4 和 Admobcomplie 'com.google.android.gms:play-services-ads:12.0.1'实现 'com.google.android.gms:play-services-ads:17.2.0'

之后,当我尝试运行应用程序时出现重复类错误。

我得到的错误

Duplicate class com.google.android.gms.common.api.internal.zza found in modules classes.jar (com.google.android.gms:play-services-base:12.0.1) and classes.jar (com.google.android.gms:play-services-basement:16.0.1)
Duplicate class com.google.android.gms.common.api.internal.zzb found in modules classes.jar (com.google.android.gms:play-services-base:12.0.1) and classes.jar (com.google.android.gms:play-services-basement:16.0.1)
Duplicate class com.google.android.gms.common.api.internal.zzc found in modules classes.jar (com.google.android.gms:play-services-base:12.0.1) and classes.jar (com.google.android.gms:play-services-basement:16.0.1)
Duplicate class com.google.android.gms.common.api.internal.zzd found in modules classes.jar (com.google.android.gms:play-services-base:12.0.1) and classes.jar (com.google.android.gms:play-services-basement:16.0.1)
Duplicate class com.google.android.gms.common.api.zza found in modules classes.jar (com.google.android.gms:play-services-base:12.0.1) and classes.jar (com.google.android.gms:play-services-basement:16.0.1)
Duplicate class com.google.android.gms.common.api.zzb found in modules classes.jar (com.google.android.gms:play-services-base:12.0.1) and classes.jar (com.google.android.gms:play-services-basement:16.0.1)
Duplicate class com.google.android.gms.common.internal.zzb found in modules classes.jar (com.google.android.gms:play-services-base:12.0.1) and classes.jar (com.google.android.gms:play-services-basement:16.0.1)
Duplicate class com.google.android.gms.common.internal.zzr found in modules classes.jar (com.google.android.gms:play-services-base:12.0.1) and classes.jar (com.google.android.gms:play-services-basement:16.0.1)
Duplicate class com.google.android.gms.common.internal.zzs found in modules classes.jar (com.google.android.gms:play-services-base:12.0.1) and classes.jar (com.google.android.gms:play-services-basement:16.0.1)
Duplicate class com.google.android.gms.common.zze found in modules classes.jar (com.google.android.gms:play-services-base:12.0.1) and classes.jar (com.google.android.gms:play-services-basement:16.0.1)

Go to the documentation to learn how to Fix dependency resolution errors.

顶级gradle


// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
repositories {
google()
jcenter()
maven { url 'https://maven.fabric.io/public' }
}
dependencies {
classpath 'com.android.tools.build:gradle:3.4.0'
classpath 'com.google.gms:google-services:4.2.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
classpath 'io.fabric.tools:gradle:1.28.1'
}
}

allprojects {
repositories {
google()
jcenter()
}
}

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

```

应用的gradle

buildscript {
repositories {
maven { url 'https://maven.fabric.io/public' }
}

dependencies {
classpath 'io.fabric.tools:gradle:1.27.1'
}
}
apply plugin: 'com.android.application'
apply plugin: 'io.fabric'

repositories {
maven { url 'https://maven.fabric.io/public' }
}


android {
useLibrary 'org.apache.http.legacy'
compileSdkVersion 27
buildToolsVersion '28.0.3'
defaultConfig {
applicationId "xx.xxx"
minSdkVersion 15
targetSdkVersion 27
versionCode 23
versionName "1.23"
multiDexEnabled true
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
manifestPlaceholders = [onesignal_app_id: "xxxx-xxx-xxx-xxx",
// Project number pulled from dashboard, local value is ignored.
onesignal_google_project_number: "REMOTE"]
}
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:recyclerview-v7:27.1.1'
implementation 'com.android.support:appcompat-v7:27.1.1'
implementation 'com.android.support:cardview-v7:27.1.1'
implementation 'com.android.support:design:27.1.1'
implementation 'com.android.support:customtabs:27.1.1'
// implementation 'com.google.android.gms:play-services-base:16.1.0'
//compile 'com.google.android.gms:play-services-gcm:12.0.1'
implementation 'com.google.android.gms:play-services-ads:17.2.0'
//compile 'com.google.android.gms:play-services-basement:16.0.1'
//compile 'com.google.android.gms:play-services-measurement-sdk-api:17.2.0'

implementation 'de.hdodenhof:circleimageview:3.0.0'
implementation 'com.github.bumptech.glide:glide:3.7.0'
implementation 'com.loopj.android:android-async-http:1.4.9'
implementation 'com.onesignal:OneSignal:3.10.8'

implementation 'com.android.support:multidex:1.0.3'
// retrofit, gson
implementation 'com.squareup.retrofit2:retrofit:2.5.0'

implementation 'org.droidparts:droidparts:3.2.5'
implementation 'org.jsoup:jsoup:1.11.3'
implementation('com.crashlytics.sdk.android:crashlytics:2.9.9@aar') {
transitive = true;
}
testImplementation 'junit:junit:4.12'
}```

最佳答案

请从这个link中查找最新的google's play service libraries| ,并相应地替换 gradle 文件中的正确版本。

在应用程序的“build.gradle”文件中,添加以下内容以及“android {...}”

configurations.all {
resolutionStrategy {
force 'com.google.android.gms:play-services-basement:17.1.0'
}
}

当时,最新的 google play services basement library 版本是 17.1.0。

希望这对您有所帮助。

关于java - 如何修复 "Duplicate class com.google.android.gms.common.api.internal.zza"错误?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56090289/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com