java - 错误 :Execution failed for task ':app:transformClassesWithJarMergingForDebug' . > com.android.build.api.transform.TransformException

标签 java android-support-library

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

我遇到了这个错误:

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'
}

最佳答案

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

1) Downgrade com.google.android.gms:play-services-auth to older version

2) Add/Migrate AndroidX to your app (Recommended)

Check this link for migration

关于java - 错误 :Execution failed for task ':app:transformClassesWithJarMergingForDebug' . > com.android.build.api.transform.TransformException,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57149570/

相关文章:

android - 更改方向后保存 Snackbar 的状态

android - 如何向嵌套在 CollapsingToolbar 中的 ImageView 添加渐变

Java- 非零 Int 除以 10 在 Float 中等于 0.0?

Java Sprite 表渲染

java - 在对话框上查找按钮时出现空指针异常

android - 借助支持库 (23.4.0),无法在 Android API 19 中正确加载 Vector Drawable

java - .restart smali 关键字有什么作用?

java - 如何创建通用数组?

android - ImageView 上的 Vectordrawable 模糊位图

安卓支持工具栏 : Resizing won't realign menu items