Android Studio报错:多个com.google.android.gms.license包冲突求助
com.google.android.gms.license Package Conflict Hey there, let's work through this duplicate package error you're hitting with Task ':app:processDebugResources'. The core issue here is almost certainly a version mismatch between the Google Play Services libraries you're manually adding and the ones that OneSignal pulls in automatically. Here's how to resolve it step by step:
1. Force a Unified Google Play Services Version
The simplest way to eliminate version conflicts is to make Gradle use the same version of all Google Play Services components across your project. Add this block inside your android section in build.gradle:
android { // ... your existing compileSdk, defaultConfig, buildTypes, etc. configurations.all { resolutionStrategy { // Match these versions to the play-services-ads version you're using (12.0.0) force 'com.google.android.gms:play-services-base:12.0.0' force 'com.google.android.gms:play-services-basement:12.0.0' force 'com.google.android.gms:play-services-license:12.0.0' } } }
This tells Gradle to ignore any conflicting version requests from other libraries and stick to the 12.0.0 versions you've specified, which will wipe out the duplicate license package issue.
2. Pin the OneSignal Version
Using a version range like [3.6.2, 3.99.99] can let Gradle pick a OneSignal version that clashes with your Play Services setup. Instead, specify a specific, stable version of OneSignal that's confirmed to work with Play Services 12.0.0. For example:
dependencies { // ... your other dependencies compile 'com.onesignal:OneSignal:3.15.0' // Use a verified compatible version }
If you're unsure which version to choose, run ./gradlew app:dependencies in your terminal to generate a dependency tree—this will show you exactly which Play Services version OneSignal is trying to pull in.
3. Clean & Rebuild Your Project
Old build artifacts can sometimes leave lingering conflicts. Run these steps to ensure a fresh build:
- Go to
Build > Clean Projectin Android Studio - Then run
Build > Rebuild Project - Alternatively, use the command line:
./gradlew clean build
Bonus: Update Outdated Build Tools
Your buildToolsVersion "23.0.3" is quite outdated and doesn't match your compileSdkVersion 27. Updating it to a compatible version (like 27.0.3) can prevent other potential build issues:
android { buildToolsVersion "27.0.3" // Match this to your compileSdkVersion }
内容的提问来源于stack exchange,提问作者Gürkan Çatak

