Как исправить ошибку «Двойной класс com.google.android.gms.common.api.internal.zza»? - PullRequest
2 голосов
/ 11 мая 2019

Я обновил Android Studio до 3.4 и Admob библиотека с complie 'com.google.android.gms:play-services-ads:12.0.1' до implementation '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'
}```
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...