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

Android Studio报错::app:processDebugResources执行失败,多库包名冲突

Fixing "more than one library with package name 'com.google.android.gms.license'" Error

Hey there, let's work through this frustrating duplicate package name error you're hitting when building your app. This is a super common issue when third-party libraries (like OneSignal) pull in their own versions of Google Play Services libraries that clash with the ones you've explicitly included. Here's how to resolve it step by step:

1. Pinpoint the Conflicting Dependencies

First, let's figure out exactly which libraries are bringing in the duplicate com.google.android.gms.license package. Run this Gradle command in your project root:

# For macOS/Linux
./gradlew app:dependencies

# For Windows
gradlew.bat app:dependencies

Search the output for com.google.android.gms:license — you'll see multiple entries with different versions, which is the root of the conflict.

2. Force a Single Version for All Google Play Services Libraries

Google requires all Play Services libraries in your project to use the same version. To enforce this, add a resolution strategy to your app-level build.gradle file (inside the android block or above the dependencies block):

configurations.all {
    resolutionStrategy {
        // Replace with the latest GMS version you're using (e.g., 21.0.0)
        force 'com.google.android.gms:play-services-license:YOUR_GMS_VERSION'
        // Optional: Force all GMS modules to match to avoid other conflicts
        force 'com.google.android.gms:play-services-base:YOUR_GMS_VERSION'
        force 'com.google.android.gms:play-services-analytics:YOUR_GMS_VERSION'
        // Add any other GMS modules your app uses
    }
}

This ensures every dependency uses the exact version of the license library you specify, eliminating duplicates.

3. Exclude the Conflicting Library from OneSignal

If OneSignal is still pulling in its own outdated license module, explicitly exclude it from your OneSignal dependency declaration:

implementation('com.onesignal:OneSignal:[3.6.2, 3.99.99]') {
    exclude group: 'com.google.android.gms', module: 'license'
}

This tells Gradle to ignore the license library that comes bundled with OneSignal and use the one you've standardized on instead.

4. Clean and Rebuild Your Project

Old build cache can sometimes hold onto conflicting files, so don't skip this step:

  • Go to Build > Clean Project in Android Studio
  • Then run Build > Rebuild Project

5. Verify Compatibility Between GMS and Compile SDK

Double-check that your compileSdkVersion matches the requirements of the latest Google Play Services version you're using. Newer GMS versions (like 20+) require a minimum compileSdkVersion of 33. If you updated GMS to the latest but kept compileSdkVersion at 27, this could cause hidden conflicts — update your compileSdkVersion to the appropriate value if needed.

Once you've followed these steps, the duplicate package name error should be resolved. The core fix is ensuring all instances of com.google.android.gms.license (and other GMS libraries) use a single, consistent version across your project.

内容的提问来源于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 03:39:24