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

编译失败求助:Android构建报错Program type already present及build.gradle问题

Fixing "Program type already present: com.google.android.gms.auth.api.signin.internal.zzo" Error

Hey there, let's tackle that annoying compilation error you're facing! This error almost always stems from duplicate or conflicting Google Play Services dependencies in your project—let's break down how to fix it step by step.

1. Unify Google Play Services Versions

The root cause here is likely mismatched versions of Google Play Services libraries across your project. Since you mentioned modifying your app's build.gradle (and realizing that wasn't the right move), let's standardize versions across all modules to avoid conflicts:

  • Open your project root build.gradle file, and add a version variable in the ext block to manage all Google Play Services dependencies centrally:
    buildscript {
        ext {
            googlePlayServicesVersion = "12.0.1" // Compatible with compileSdkVersion 27
        }
        // ... rest of your existing buildscript code
    }
    
  • Now, in your app module's build.gradle, update all Google Play Services dependencies to use this unified version. For example:
    implementation "com.google.android.gms:play-services-auth:$googlePlayServicesVersion"
    implementation "com.google.android.gms:play-services-maps:$googlePlayServicesVersion"
    // Repeat for any other com.google.android.gms dependencies you're using
    
    Note: 12.0.1 is a stable version compatible with compileSdkVersion 27—you can use a newer compatible version if needed, just make sure all gms libraries use the same one.

2. Identify & Remove Duplicate Dependencies

Sometimes third-party libraries might secretly include old versions of Google Play Services, causing duplicates. To find these:

  • Run this command in your project's root directory (via terminal or Android Studio's Terminal tab):
    ./gradlew app:dependencies
    
  • Search the output for com.google.android.gms.auth entries. If you see multiple versions or duplicate references, exclude the conflicting one from the third-party dependency. For example:
    implementation('com.example.third-party-library:1.0.0') {
        exclude group: 'com.google.android.gms', module: 'play-services-auth'
    }
    

3. Revert Unnecessary build.gradle Changes

Since you mentioned modifying your app's build.gradle incorrectly earlier, revert any changes that aren't related to dependency versioning (like arbitrary tweaks to compileSdkVersion or targetSdkVersion if they were working before). Keep compileSdkVersion 27 and targetSdkVersion 27 as they are now—those are fine as long as your dependencies support them.

4. Clean & Rebuild Your Project

After making these changes, clear cached build files and rebuild to apply fixes:

  • In Android Studio, go to Build > Clean Project
  • Then select Build > Rebuild Project
  • Alternatively, run this terminal command:
    ./gradlew clean assembleDebug
    

Why This Works

The Program type already present error happens when the D8 compiler finds multiple copies of the same class (in this case, com.google.android.gms.auth.api.signin.internal.zzo) from different dependencies. By unifying versions and removing duplicates, you eliminate these conflicting class definitions.

内容的提问来源于stack exchange,提问作者Fazer01

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.05.22 08:09:46