生成签名 APK 时,出现“androidx.legacy_legacy-support-core-utils.version 冲突”错误

Vis*_*har 5 android android-studio build.gradle signed-apk

在尝试生成签名的 APK 时,它显示以下错误消息。

条目名称“META-INF/androidx.legacy_legacy-support-core-utils.version”发生冲突

以前它可以正常工作几年。此外,我还检查了另一台具有相同 android studio 和相同 gradle 版本的 PC,它在该 PC 中正常工作。我遇到这个问题,特别是一台 PC 本身为什么?我在下面附上了 build.gradle。

apply plugin: 'com.android.application'

android {
    compileSdkVersion 29

    defaultConfig {
        minSdkVersion 19
        targetSdkVersion 29
        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
        multiDexEnabled true
        vectorDrawables {
            useSupportLibrary = true
        }
    }

        compileOptions {
            sourceCompatibility JavaVersion.VERSION_1_8
            targetCompatibility JavaVersion.VERSION_1_8
        }


    //--Test
    lintOptions {
        checkReleaseBuilds false
    }



    flavorDimensions "default"



    buildTypes {
        publicDebug {
            minifyEnabled false
            initWith debug
            //shrinkResources true
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'


        }



        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'

        }
    }

    sourceSets {
        main {
            res.srcDirs =
                    [
                            'src/main/res/layouts/stripchart/layout',
                            'src/main/res/layouts/stripchart',
                            'src/main/res/layouts/erfi/layout',
                            'src/main/res/layouts/erfi',
                            'src/main/res/layouts',
                            'src/main/res'
                    ]
        }
    }

    android {
        useLibrary 'org.apache.http.legacy'
    }

}


dependencies {
    implementation fileTree(include: ['*.jar'], dir: 'libs')
    implementation 'androidx.appcompat:appcompat:1.1.0'
    implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
    testImplementation 'junit:junit:4.13'
    androidTestImplementation 'androidx.test:runner:1.2.0'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
    implementation 'androidx.cardview:cardview:1.0.0'
    implementation 'androidx.multidex:multidex:2.0.1'
    // Glide image library
    implementation 'com.github.bumptech.glide:glide:4.11.0'
    //material design
    implementation 'com.google.android.material:material:1.0.0'
    //Circular Image view
    implementation 'com.mikhaellopez:circularimageview:3.0.2'
    //Expandable layout
    implementation 'com.github.florent37:expansionpanel:1.1.1'
    //Vector drawables\
    implementation 'androidx.vectordrawable:vectordrawable-animated:1.1.0'
    //Animated jsons
    implementation 'com.airbnb.android:lottie:3.4.0'
    // Dexter runtime permissions
    implementation 'com.karumi:dexter:6.0.2'
    implementation 'com.squareup.retrofit2:retrofit:2.6.0'
    implementation 'com.squareup.okhttp3:logging-interceptor:3.12.0'
    implementation 'com.squareup.retrofit2:converter-gson:2.6.0'
    implementation 'com.google.code.gson:gson:2.8.6'
    //DotsIndicator
    implementation 'com.tbuonomo.andrui:viewpagerdotsindicator:2.0.3'
    //DateTimePciker BottomSheet
    implementation 'com.github.florent37:singledateandtimepicker:2.0.4'
    implementation 'com.google.android.gms:play-services-location:17.0.0'
    //Location settings
    implementation 'io.nlopez.smartlocation:library:3.3.3'
    implementation 'androidx.legacy:legacy-support-v13:1.0.0'

    implementation 'org.florescu.android.rangeseekbar:rangeseekbar-library:0.4.0'

    //Digital Signature
    implementation 'com.kyanogen.signatureview:signature-view:1.0'

    // Shimmer
    // implementation 'com.facebook.shimmer:shimmer:0.5.0'

}
Run Code Online (Sandbox Code Playgroud)

请任何人帮助解决这个问题。我在哪里错过了什么?

Vis*_*har 10

我找到了问题的根源。它在output.json 中。它是罪魁祸首。由于某些活动,该文件已损坏。我们必须从签名 APK 生成的目标文件夹中删除该文件。它解决了这个问题。

  • 谢谢!“构建/清理项目”对我来说就是诀窍。 (4认同)