You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Android Studio报错:多个com.google.android.gms.license包冲突求助

Fixing Duplicate 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 Project in 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

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.21 04:00:05