0

我是安卓新手。我正在尝试在我的应用中添加 Google 登录功能,但是当我添加com.google.android.gms:play-services-auth:17.0.0到我的build.gradle文件中时,

我正在关注此错误:

Error:Execution failed for task ':app:transformClassesWithJarMergingForDebug'.
com.android.build.api.transform.TransformException: java.util.zip.ZipException: duplicate entry: androidx/versionedparcelable/CustomVersionedParcelable.class

请提出解决方案,我花了一整天但无法获得解决方案。

Build.gradle代码是:

apply plugin: 'com.android.application'

android {
    compileSdkVersion 28
    buildToolsVersion "29.0.1"
    defaultConfig {
        multiDexEnabled true
        applicationId "com.example.mawai.smartlearn"
        minSdkVersion 15
        targetSdkVersion 26
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
     compile 'com.android.support:multidex:1.0.0'

    compile fileTree(dir: 'libs', include: ['*.jar'])
    androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
        exclude group: 'com.android.support', module: 'support-annotations'
    })
    // compile 'com.android.support:appcompat-v7:26.+'
     compile 'com.android.support:appcompat-v7:28.0.0'
    compile 'com.android.support.constraint:constraint-layout:1.0.2'
    testCompile 'junit:junit:4.12'

     compile 'com.google.android.gms:play-services-auth:17.0.0'
}
4

1 回答 1

2

在 17.0.0 及以上版本中,您需要使用 AndroidX,因此您有2 个选项

1) 将com.google.android.gms:play-services-auth降级为旧版本

2) 将 AndroidX 添加/迁移到您的应用程序(推荐)

检查此链接以进行迁移

于 2019-07-22T17:49:15.157 回答