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

Android Studio编译报错:Program type already present: com.google.android.gms.internal.measurement.zzwp

Fixing "Program type already present: com.google.android.gms.internal.measurement.zzwp" Error

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:dependencies
    

    Search the output for com.google.android.gms:play-services-measurement and its related modules (like play-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-level build.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.gradle to 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 clean
    

    Then close Android Studio, delete the .gradle folder 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-level build.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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.05.26 10:35:12