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

Android Studio 3.1.1报错:Program type already present: com.google.android.gms.common.internal.zze

Fixing "Program type already present: com.google.android.gms.common.internal.zze" in Android Studio 3.1.1

Hey there, I’ve dealt with this exact error a few times when working with Google Play Services and Firebase dependencies, so let me break down what’s going on and how to fix it.

What’s causing this error?

This error boils down to a dependency conflict. Your project has multiple versions of Google Play Services (or Firebase) libraries that all include the com.google.android.gms.common.internal.zze class. The D8 compiler throws this error when it encounters duplicate class definitions across your dependencies.

Step-by-step fixes

  • 统一所有Google Play Services/Firebase依赖版本
    The most common fix is making sure all your Google Play Services and Firebase dependencies use the same version. Here’s how:

    1. Open your project-level build.gradle file, and add a version variable in the buildscript block:
      buildscript {
          ext {
              googleServicesVersion = "12.0.1" // Use a stable version compatible with your project
          }
          // ... other existing configuration
      }
      
    2. In your module-level build.gradle file, replace hardcoded versions with this variable for all GMS/Firebase dependencies:
      implementation "com.google.android.gms:play-services-location:$googleServicesVersion"
      implementation "com.google.firebase:firebase-database:$googleServicesVersion"
      

    This ensures no mismatched versions are pulling in duplicate classes.

  • Identify and exclude duplicate dependencies
    If you’re not sure which library is causing the conflict, run this Gradle command in your terminal to analyze dependencies:

    ./gradlew app:dependencies
    

    Look for entries under com.google.android.gms with different versions. Once you find the culprit, exclude the conflicting group from that dependency:

    implementation('third-party-library:some-lib:1.0.0') {
        exclude group: 'com.google.android.gms'
    }
    
  • Update the Google Services plugin
    Make sure the Google Services plugin version in your project-level build.gradle matches your GMS dependency version. For example:

    buildscript {
        dependencies {
            classpath "com.google.gms:google-services:4.0.1" // Match this to your GMS version
        }
    }
    

    Outdated plugins often cause version mismatch issues that lead to duplicate class errors.

  • Clean and rebuild your project
    After making these changes, clear your project’s build cache and rebuild:

    1. Go to Build > Clean Project in the Android Studio menu
    2. Then run Build > Rebuild Project
      This ensures no cached old dependencies are causing lingering issues.

A quick note

Android Studio 3.1.1 is a bit outdated, so if you can, consider upgrading to a more recent stable version—it’ll have better dependency resolution and fewer bugs. But if you’re stuck on 3.1.1, the steps above should still resolve the error.

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.05.25 07:48:59