生成签名APK遇重复条目错误,请求技术排查解决
Hey, I’ve dealt with this exact duplicate entry issue multiple times, so let’s break down the most reliable fixes to get you past this:
Track down duplicate dependencies first
Run this command in your project root to generate a full dependency tree—it’ll show you exactly which libraries are pulling in duplicate copies of the support design library:# For macOS/Linux ./gradlew app:dependencies # For Windows gradlew.bat app:dependenciesLook for entries of
com.android.support:designthat come from more than one source (e.g., your direct dependency plus a third-party library). Once you spot the duplicate, exclude the extra one from the third-party dependency like this:implementation('com.example.third-party:library:1.2.3') { exclude group: 'com.android.support', module: 'design' }Unify all support library versions
Mismatched versions of Android Support libraries (likeappcompat-v7,design,recyclerview-v7) are a super common cause of this error. Make sure every support library in yourdependenciesblock uses the exact same version number.
To make this easier, define a version variable in your rootbuild.gradle:ext { supportLibVersion = '28.0.0' // Use the latest stable version you need }Then reference it in your app module’s
build.gradle:implementation "com.android.support:appcompat-v7:$supportLibVersion" implementation "com.android.support:design:$supportLibVersion" implementation "com.android.support:recyclerview-v7:$supportLibVersion"Clean up caches and rebuild
Gradle caches can sometimes hold onto old, conflicting files. Try these steps:- Go to
Build > Clean Projectin Android Studio - Then run
Build > Rebuild Project - If that doesn’t work, manually delete the
.gradlefolder (in your project root and app module) and thebuildfolders, then re-sync your Gradle project.
- Go to
Check for AndroidX/Support Library conflicts
If you’ve started migrating to AndroidX, you can’t mix old Support Libraries with AndroidX dependencies. Check yourgradle.propertiesfile:android.useAndroidX=true android.enableJetifier=trueIf these lines are present, replace all old Support Library dependencies with their AndroidX equivalents (e.g., use
com.google.android.material:material:1.5.0instead ofcom.android.support:design). If you haven’t migrated, make sure none of your dependencies are pulling in AndroidX libraries.
If none of these fixes work, share your full build.gradle code (especially the dependencies section) and I can help you pinpoint the exact conflict.
内容的提问来源于stack exchange,提问作者Shubham Sejpal

