如何解决"Duplicate class com.google.android.gms.common.api.zzb found in modules jetified-play-services-base-11.0.1-runtime.jar"
How to resolve "Duplicate class com.google.android.gms.common.api.zzb found in modules jetified-play-services-base-11.0.1-runtime.jar"
我是 Android Studio Development 的新手。我在我的项目中遇到这个错误。
Duplicate class com.google.android.gms.common.api.zzb found in modules jetified-play-services-base-11.0.1-runtime.jar
这是我的应用程序 Gradle dependencies 代码 (build.gradle (Module: app))
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'androidx.appcompat:appcompat:1.1.0'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test.ext:junit:1.1.1'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
implementation 'com.google.android.gms:play-services-ads:18.3.0'
implementation 'com.google.android.gms:play-services:11.0.1'
}
这是完整的错误:
Cause 1: java.util.concurrent.ExecutionException: java.lang.RuntimeException: Duplicate class com.google.android.gms.common.api.zza found in modules jetified-play-services-base-11.0.1-runtime.jar (com.google.android.gms:play-services-base:11.0.1) and jetified-play-services-basement-17.0.0-runtime.jar (com.google.android.gms:play-services-basement:17.0.0)
Duplicate class com.google.android.gms.common.api.zzb found in modules jetified-play-services-base-11.0.1-runtime.jar (com.google.android.gms:play-services-base:11.0.1) and jetified-play-services-basement-17.0.0-runtime.jar (com.google.android.gms:play-services-basement:17.0.0)
Duplicate class com.google.android.gms.common.internal.zzb found in modules jetified-play-services-base-11.0.1-runtime.jar (com.google.android.gms:play-services-base:11.0.1) and jetified-play-services-basement-17.0.0-runtime.jar (com.google.android.gms:play-services-basement:17.0.0)
Duplicate class com.google.android.gms.common.internal.zzq found in modules jetified-play-services-base-11.0.1-runtime.jar (com.google.android.gms:play-services-base:11.0.1) and jetified-play-services-basement-17.0.0-runtime.jar (com.google.android.gms:play-services-basement:17.0.0)
Duplicate class com.google.android.gms.common.internal.zzr found in modules jetified-play-services-base-11.0.1-runtime.jar (com.google.android.gms:play-services-base:11.0.1) and jetified-play-services-basement-17.0.0-runtime.jar (com.google.android.gms:play-services-basement:17.0.0)
Duplicate class com.google.android.gms.common.internal.zzs found in modules jetified-play-services-base-11.0.1-runtime.jar (com.google.android.gms:play-services-base:11.0.1) and jetified-play-services-basement-17.0.0-runtime.jar (com.google.android.gms:play-services-basement:17.0.0)
我在我的项目中使用 FusedLocation 服务以及 Google 广告 (Admob)。
import com.google.android.gms.common.api.GoogleApi;
import com.google.android.gms.location.FusedLocationProviderClient;
import android.location.Location;
import com.google.android.gms.ads.AdView;
import com.google.android.gms.ads.InterstitialAd;
import com.google.android.gms.ads.MobileAds;
public class MainActivity extends AppCompatActivity
{
private AdView adView;
private InterstitialAd interstitialAd;
FusedLocationProviderClient client;
...
删除这一行:
implementation 'com.google.android.gms:play-services:11.0.1'
play-services-ads:18.3.0
将引入一个相当新的版本,不需要进行 jetified。
我是 Android Studio Development 的新手。我在我的项目中遇到这个错误。
Duplicate class com.google.android.gms.common.api.zzb found in modules jetified-play-services-base-11.0.1-runtime.jar
这是我的应用程序 Gradle dependencies 代码 (build.gradle (Module: app))
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'androidx.appcompat:appcompat:1.1.0'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test.ext:junit:1.1.1'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
implementation 'com.google.android.gms:play-services-ads:18.3.0'
implementation 'com.google.android.gms:play-services:11.0.1'
}
这是完整的错误:
Cause 1: java.util.concurrent.ExecutionException: java.lang.RuntimeException: Duplicate class com.google.android.gms.common.api.zza found in modules jetified-play-services-base-11.0.1-runtime.jar (com.google.android.gms:play-services-base:11.0.1) and jetified-play-services-basement-17.0.0-runtime.jar (com.google.android.gms:play-services-basement:17.0.0)
Duplicate class com.google.android.gms.common.api.zzb found in modules jetified-play-services-base-11.0.1-runtime.jar (com.google.android.gms:play-services-base:11.0.1) and jetified-play-services-basement-17.0.0-runtime.jar (com.google.android.gms:play-services-basement:17.0.0)
Duplicate class com.google.android.gms.common.internal.zzb found in modules jetified-play-services-base-11.0.1-runtime.jar (com.google.android.gms:play-services-base:11.0.1) and jetified-play-services-basement-17.0.0-runtime.jar (com.google.android.gms:play-services-basement:17.0.0)
Duplicate class com.google.android.gms.common.internal.zzq found in modules jetified-play-services-base-11.0.1-runtime.jar (com.google.android.gms:play-services-base:11.0.1) and jetified-play-services-basement-17.0.0-runtime.jar (com.google.android.gms:play-services-basement:17.0.0)
Duplicate class com.google.android.gms.common.internal.zzr found in modules jetified-play-services-base-11.0.1-runtime.jar (com.google.android.gms:play-services-base:11.0.1) and jetified-play-services-basement-17.0.0-runtime.jar (com.google.android.gms:play-services-basement:17.0.0)
Duplicate class com.google.android.gms.common.internal.zzs found in modules jetified-play-services-base-11.0.1-runtime.jar (com.google.android.gms:play-services-base:11.0.1) and jetified-play-services-basement-17.0.0-runtime.jar (com.google.android.gms:play-services-basement:17.0.0)
我在我的项目中使用 FusedLocation 服务以及 Google 广告 (Admob)。
import com.google.android.gms.common.api.GoogleApi;
import com.google.android.gms.location.FusedLocationProviderClient;
import android.location.Location;
import com.google.android.gms.ads.AdView;
import com.google.android.gms.ads.InterstitialAd;
import com.google.android.gms.ads.MobileAds;
public class MainActivity extends AppCompatActivity
{
private AdView adView;
private InterstitialAd interstitialAd;
FusedLocationProviderClient client;
...
删除这一行:
implementation 'com.google.android.gms:play-services:11.0.1'
play-services-ads:18.3.0
将引入一个相当新的版本,不需要进行 jetified。