问题“条目名称‘META-INF/android.support.design_material.version’发生冲突”Android studio

问题描述

我只是复制了我的项目,(我想要有 2 个有细微差别的独立应用程序)。我为第二个更改了包名和 applicationId,它在模拟器上完美运行,但是当我尝试生成签名的 apk 时出现此错误

Entry name 'meta-inf/android.support.design_material.version' collided

虽然我可以为我的第一个应用程序完美地做到这一点。

我多次尝试重建和清理项目,但没有任何效果

这是我的应用程序/build.gradle:

apply plugin: 'com.android.application'

android {


compileOptions {
    sourceCompatibility JavaVersion.VERSION_1_8
    targetCompatibility JavaVersion.VERSION_1_8
}

compileSdkVersion 30

defaultConfig {
    applicationId "com.example.apptest"
    minSdkVersion 19
    targetSdkVersion 30
    versionCode 1
    versionName "1.0"
    multiDexEnabled true
    testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}

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

dependencies {
    implementation filetree(dir: "libs",include: ["*.jar"])
    implementation 'androidx.appcompat:appcompat:1.2.0'
    implementation 'androidx.constraintlayout:constraintlayout:2.0.4'
    implementation 'androidx.legacy:legacy-support-v4:1.0.0'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'androidx.test.ext:junit:1.1.2'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
    implementation 'com.android.volley:volley:1.1.1'
    //noinspection GradleCompatible
    implementation 'com.android.support:design:28.0.0'
    implementation 'com.rengwuxian.materialedittext:library:2.1.4'
    implementation "androidx.cardview:cardview:1.0.0"
    // https://mvnrepository.com/artifact/com.google.guava/guava
    implementation group: 'com.google.guava',name: 'guava',version: '30.1-jre'
    implementation 'com.github.barteksc:android-pdf-viewer:2.8.2'
    android.defaultConfig.vectorDrawables.useSupportLibrary = true
    implementation 'de.hdodenhof:circleimageview:3.1.0'
    implementation "androidx.recyclerview:recyclerview:1.2.0"
    implementation 'com.github.danylovolokh:LondonEyeLayoutManager:1fb6469521'
    implementation 'com.github.leochuan:ViewPagerLayoutManager:v2.0.22'
    implementation 'com.squareup.okhttp3:okhttp:4.2.0'
    implementation 'com.github.rtoshiro:FullscreenVideoView:1.1.2'
    implementation 'androidx.multidex:multidex:2.0.1'


}

如果还有什么我需要放在这里,请告诉我。 请帮助我并告诉我我做错了什么,我应该怎么做。 谢谢。

PS:两个应用都有不同的键。 PS:我也尝试删除现有的 APK。没用。

解决方法

进行清理和重建项目:

Menu -> Build -> Clean project
File -> Invalidate Caches / Restart
Build —> Rebuild Project

重建项目应该可以解决。但由于它无法解决您的问题,请查看应用程序的输出目录中是否有任何应用程序文件。如果是,请删除或重命名它。由于某种原因,android sdk 似乎无法覆盖它。或者,您可以从 app 文件夹中完全删除 debug 和 release 文件夹,然后重新启动 IDE。

如果以上方法都不能解决您的问题,那么在您的应用构建 Gradle 中添加以下内容,然后清理,重建您的项目。

packaging options{ exclude 'META-INF/android.support.design_material.version' }