更新依赖库后出现重复Zip条目及Dex合并失败问题求助
Got it, you’re right to pair Firebase/Play Services 15.0.0 with FirebaseUI 3.3.1— that’s the correct match per the docs. The problem here is almost certainly transitive dependencies pulling in conflicting versions of shared libraries (like Firebase components or Android Support libraries) that override your explicit implementation declarations.
Here’s how to resolve this step by step:
1. Identify Conflicting Dependencies
First, let’s pinpoint exactly which libraries are causing the mismatch. Run this command from your project’s root directory to generate a full dependency tree:
./gradlew app:dependencies
Look for entries under com.google.firebase, com.google.android.gms, or com.android.support that have versions different from 15.0.0 (for Firebase/Play Services) or 27.1.1 (the Support Library version FirebaseUI 3.3.1 relies on).
2. Force Correct Versions
Add a configurations block to your app-level build.gradle file. This tells Gradle to override any transitive dependency versions with the ones you specify:
configurations.all { resolutionStrategy { // Force Firebase/Play Services to 15.0.0 force 'com.google.firebase:firebase-core:15.0.0' force 'com.google.android.gms:play-services-auth:15.0.0' // Add any other Firebase/Play Services modules you're using here // Force Support Library versions compatible with FirebaseUI 3.3.1 force 'com.android.support:appcompat-v7:27.1.1' force 'com.android.support:design:27.1.1' force 'com.android.support:cardview-v7:27.1.1' } }
3. Update Your Dependencies Block
Make sure your dependencies explicitly include FirebaseUI and the Firebase components you need, with their correct versions. Here’s how your updated block might look:
dependencies { compile fileTree(dir: 'libs', include: ['*.jar']) // FirebaseUI modules (add only what you use) implementation 'com.firebaseui:firebase-ui-auth:3.3.1' implementation 'com.firebaseui:firebase-ui-database:3.3.1' // Matching Firebase/Play Services implementation 'com.google.firebase:firebase-core:15.0.0' implementation 'com.google.android.gms:play-services-auth:15.0.0' // Keep your existing test dependencies androidTestCompile('com.android.support.test.espresso:espresso-core:3.0.2', { exclude group: 'com.android.support', module: 'support-annotations' }) }
4. Sync & Clean Build
After making these changes:
- Sync your project with Gradle files (click the "Sync Now" prompt in Android Studio)
- Run a clean build to ensure all dependencies are properly resolved:
./gradlew clean build
This should eliminate the transitive dependency conflicts by forcing all libraries to use versions compatible with your FirebaseUI and Firebase/Play Services setup.
内容的提问来源于stack exchange,提问作者Rohit

