I have updated Android Studio to 3.4 and Admob
library from
complie 'com.google.android.gms:play-services-ads:12.0.1'
to
implementation 'com.google.android.gms:play-services-ads:17.2.0'
After that I got duplicate class error when I tried to run app.
Error i got
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.
Top level 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
}
```
App's 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'
}```
Please look up the latest google's play service libraries from this link, and replace the correct version in your gradle file accordingly.
In the app's "build.gradle" file, add the following along with "android {...}"
configurations.all {
resolutionStrategy {
force 'com.google.android.gms:play-services-basement:17.1.0'
}
}
At the time, the lastest google play services basement library version is 17.1.0.
Hope this helps.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With