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

添加Google Photos API依赖后出现Duplicate Class错误求助

Fix: Duplicate Class Error After Adding Google Photos Library API Dependency

The Problem

You're hitting duplicate class conflicts after adding com.google.photos.library:google-photos-library-client:1.5.0 to your Android project. The error points to overlapping classes like com.google.api.Advice that exist in both proto-google-common-protos-1.17.0.jar (from Google Photos) and protolite-well-known-types-17.0.0-runtime.jar (from Firebase dependencies).

The Solution

This conflict happens because the Google Photos client pulls in proto-google-common-protos, which shares identical proto-generated classes with Firebase's protolite-well-known-types. Here's how to resolve it:

  1. Exclude the conflicting dependency from Google Photos
    Modify your Google Photos dependency entry in your module-level build.gradle to exclude the duplicate library:

    implementation('com.google.photos.library:google-photos-library-client:1.5.0') {
        exclude group: 'com.google.api.grpc', module: 'proto-google-common-protos'
    }
    
  2. Verify the dependency tree (optional but recommended)
    Run this command in your project's terminal to confirm the duplicate dependency is removed:

    ./gradlew app:dependencies
    

    Search for proto-google-common-protos in the output—you should no longer see it listed under the Google Photos dependency.

  3. Clean and rebuild your project

    • Go to Build > Clean Project in Android Studio
    • Then run Build > Rebuild Project to ensure all changes take effect

Why This Works

Firebase's protolite-well-known-types is a lightweight implementation of the common protobuf types, and it's fully compatible with the classes that Google Photos needs. By excluding the heavier proto-google-common-protos from the Google Photos dependency, we let the project use Firebase's version exclusively, eliminating the class conflict.

Bonus Tips

If you still run into duplicate class issues:

  • Check other dependencies to see if any also pull in proto-google-common-protos, and apply the same exclusion rule to them
  • Update your Firebase dependencies to the latest stable versions—newer releases often include dependency conflict fixes

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.05.08 10:12:50