Android Studio编译报错:Program type already present: com.google.android.gms.internal.measurement.zzwp
Hey there, I’ve run into this exact error a bunch of times—it’s almost always caused by conflicting versions of Google Play Services dependencies, specifically the measurement-related libraries. Let’s walk through the most reliable fixes step by step:
First, identify the conflicting dependencies
Run this command in your project root to generate a full dependency tree (it’ll show every library your app is pulling in, directly or indirectly):# For macOS/Linux ./gradlew app:dependencies # For Windows gradlew.bat app:dependenciesSearch the output for
com.google.android.gms:play-services-measurementand its related modules (likeplay-services-measurement-sdk-api). You’ll likely see multiple versions of the same library being pulled in by different dependencies.Unify all Play Services versions
The easiest way to avoid version conflicts is to define a single version variable for all Play Services libraries in your project-levelbuild.gradle:buildscript { ext { play_services_version = "17.0.0" // Use a stable, compatible version here } // ... rest of your buildscript config }Then update every Play Services dependency in your app-level
build.gradleto use this variable, e.g.:implementation "com.google.android.gms:play-services-analytics:$play_services_version" implementation "com.google.android.gms:play-services-auth:$play_services_version"This ensures all related libraries use the same version, eliminating conflicts.
Exclude conflicting dependencies manually
If a third-party library is forcing an older or incompatible version of the measurement library, you can exclude it directly from that dependency. For example:implementation('com.some.thirdparty:library:1.2.3') { exclude group: 'com.google.android.gms', module: 'play-services-measurement' exclude group: 'com.google.android.gms', module: 'play-services-measurement-sdk-api' }Clean your project and restart Android Studio
Old build cache can sometimes stick around and cause weird issues. Run:# macOS/Linux ./gradlew clean # Windows gradlew.bat cleanThen close Android Studio, delete the
.gradlefolder in your project root, and restart the IDE before rebuilding.Use Firebase BOM if you’re using Firebase
If your app uses Firebase services (like Analytics), the Firebase Bill of Materials (BOM) automatically manages compatible versions for all Firebase and related Play Services libraries. Add this to your app-levelbuild.gradle:implementation platform('com.google.firebase:firebase-bom:32.7.0') // Use the latest stable BOM version implementation 'com.google.firebase:firebase-analytics'With the BOM, you don’t need to specify versions for individual Firebase dependencies—it handles version alignment for you.
Give these steps a shot—9 times out of 10, either unifying versions or excluding the conflicting library will resolve this error. If you still run into issues, feel free to share snippets of your build.gradle files and I can help dig deeper!
内容的提问来源于stack exchange,提问作者Caio Araújo

