6

I am new in Android Studio Development. I am getting this error in my project.

Duplicate class com.google.android.gms.common.api.zzb found in modules jetified-play-services-base-11.0.1-runtime.jar

Here is my App Gradle dependencies code (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'
}

Here is the full error:

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)

I am using FusedLocation Service as well as Google Ads (Admob) in my project.

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;
    ...
Junaid Pathan
  • 3,850
  • 1
  • 25
  • 47

2 Answers2

8

Remove this line:

implementation 'com.google.android.gms:play-services:11.0.1'

play-services-ads:18.3.0 will pull in a rather current version, which doesn't need to be jetified.

Martin Zeitler
  • 1
  • 19
  • 155
  • 216
  • I am using "import com.google.android.gms.common.api.GoogleApi" and "FusedLocationProviderClient" in my MainActivity.java. When I remove that line as you suggested, I am getting error "cannot find symbol class GoogleApi" and "package com.google.android.gms.location does not exist". – Junaid Pathan Nov 12 '19 at 10:14
  • 3
    @JunedKhanMomin add this one instead: `com.google.android.gms:play-services-location:17.0.0`; [here](https://developers.google.com/android/guides/setup#add_google_play_services_to_your_project) you can find all the current versions. – Martin Zeitler Nov 12 '19 at 10:27
0

Issue was resolved when I updated the com.google.android.gms:play-services-cast-framework library to the latest version.

Harshal Pudale
  • 178
  • 1
  • 2
  • 7