while implementing GCS, Duplicate class found error after adding implementation 'com.google.cloud:google-cloud-storage' in gradle android

huangapple go评论90阅读模式
英文:

while implementing GCS, Duplicate class found error after adding implementation 'com.google.cloud:google-cloud-storage' in gradle android

问题

当我将Google Cloud Storage实现添加到我的现有Android应用程序中的Gradle中(implementation 'com.google.cloud:google-cloud-storage:1.113.1'),我遇到了以下依赖错误:

重复的类 com.google.api.Advice 在模块 jetified-proto-google-common-protos-1.18.1.jar 中找到
重复的类 com.google.api.Advice$1 在模块 jetified-proto-google-common-protos-1.18.1.jar 中找到
重复的类 com.google.api.Advice$Builder 在模块 jetified-proto-google-common-protos-1.18.1.jar 中找到
重复的类 com.google.api.AnnotationsProto 在模块 jetified-proto-google-common-protos-1.18.1.jar 中找到
重复的类 com.google.api.AuthProto 在模块 jetified-proto-google-common-protos-1.18.1.jar 中找到
...(以下类似)

我正在获得类似的错误行数超过100行,请帮助
这是我的 build.gradle 文件

(接下来是您提供的 build.gradle 文件内容)

我尝试了排除依赖组的方式,但没有帮助:

implementation('com.google.apis:google-api-services-translate:v2-rev47-1.22.0'){
exclude group:'com.google.guava'
}
implementation('com.google.cloud:google-cloud-translate:0.5.0'){
exclude group:'io.grpc',module:'grpc-all'
exclude group:'com.google.protobuf',module:'protobuf-java'
exclude group:'com.google.api-client',module:'google-api-client-appengine'
exclude group:'com.google.api.Advice',module:'jetified-proto-google-common-protos'
}

我还尝试了以下方式:

android {
packagingOptions {
// 排除的内容...
exclude 'google/api/Advice'
exclude 'google/api/AdviceOrBuilder'
}
}

我检查了所有已有的答案,但没有找到解决方案。

如果我移除 implementation 'com.google.cloud:google-cloud-storage:1.113.1',一切都正常工作。

但是我需要将云存储实现添加到我的Android应用程序中以存储图像。

非常感谢您的帮助。

英文:

when i add Google cloud storage implementation to my existing android app, in gradle
( implementation 'com.google.cloud:google-cloud-storage:1.113.1' ) ,
i am getting these dependency errors

Duplicate class com.google.api.Advice found in modules jetified-proto-google-common-protos-1.18.1.jar
Duplicate class com.google.api.Advice$1 found in modules jetified-proto-google-common-protos-1.18.1.jar
Duplicate class com.google.api.Advice$Builder found in modules jetified-proto-google-common-protos-1.18.1.jar
Duplicate class com.google.api.AnnotationsProto found in modules jetified-proto-google-common-protos-1.18.1.jar
Duplicate class com.google.api.AuthProto found in modules jetified-proto-google-common-protos-1.18.1.jar
Duplicate class com.google.api.AuthProvider found in modules jetified-proto-google-common-protos-1.18.1.jar
Duplicate class com.google.api.AuthProvider$1 found in modules jetified-proto-google-common-protos-1.18.1.jar
Duplicate class com.google.api.AuthProvider$Builder found in modules jetified-proto-google-common-protos-1.18.1.jar
Duplicate class com.google.api.AuthProviderOrBuilder found in modules jetified-proto-google-common-protos-1.18.1.jar
Duplicate class com.google.api.AuthRequirement found in modules jetified-proto-google-common-protos-1.18.1.jar
Duplicate class com.google.api.AuthRequirement$1 found in modules jetified-proto-google-common-protos-1.18.1.jar
Duplicate class com.google.api.AuthRequirement$Builder found in modules jetified-proto-google-common-protos-1.18.1.jar
Duplicate class com.google.api.AuthRequirementOrBuilder found in modules jetified-proto-google-common-protos-1.18.1.jar
Duplicate class com.google.api.Authentication found in modules jetified-proto-google-common-protos-1.18.1.jar

like this i am getting 100's of lines please help
here my build.gradle file

apply plugin: 'com.android.application'

apply plugin: 'io.fabric'

repositories {
    maven { url 'https://maven.fabric.io/public' }
    mavenCentral()

}

android {
    compileSdkVersion 29
    defaultConfig {
        applicationId "XXXXXXXXXXXXXXXXXX"
        //noinspection StringShouldBeInt
        minSdkVersion 19
        targetSdkVersion 29
        versionCode 6
        versionName "1.6"
        multiDexEnabled true
        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"

    }

    android {
        packagingOptions {
            exclude 'META-INF/DEPENDENCIES'
            exclude 'META-INF/INDEX.LIST'
            exclude 'google/protobuf/field_mask.proto'
            exclude 'google/protobuf/type.proto'
            exclude 'google/protobuf/api.proto'
            exclude 'google/protobuf/empty.proto'
            exclude 'google/protobuf/source_context.proto'
            exclude 'google/protobuf/wrappers.proto'
            exclude 'google/protobuf/struct.proto'
            exclude 'google/protobuf/any.proto'
            exclude 'google/protobuf/timestamp.proto'
            exclude 'google/protobuf/AbstractMessageLite'
            exclude 'google/protobuf/WireFormat'
            exclude 'google/protobuf/WrappersProto'
            exclude 'google/protobuf/Writer'
            
            exclude 'google/api/Advice'
            exclude 'google/api/AdviceOrBuilder'
             
        }

    }

    buildTypes {
        release {
            minifyEnabled true
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
            zipAlignEnabled true
            shrinkResources true

        }
        debug {
            minifyEnabled false
        }
    }



}

dependencies {

    //--required
    //progress bar
    implementation 'com.victor:lib:1.0.4'
//wallpaper
    implementation 'com.github.bumptech.glide:glide:4.9.0'
    //auto update
    implementation 'org.jsoup:jsoup:1.13.1'
    //tablayout
    implementation 'com.google.android.material:material:1.2.1'
    //rain layout
    implementation 'com.luolc:emoji-rain:0.1.1'
    implementation 'com.gauravk.bubblenavigation:bubblenavigation:1.0.7'
    //counter animation
     implementation 'com.robinhood.ticker:ticker:2.0.2'
    // round imageview
   implementation 'com.joooonho:selectableroundedimageview:1.0.1'
    implementation 'com.github.mklimek:frame-video-view:1.3.3'
    implementation 'com.squareup.picasso:picasso:2.71828'

    implementation 'com.daimajia.easing:library:2.4@aar'
    implementation 'com.daimajia.androidanimations:library:2.4@aar'

    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation files('libs/...')

   


    
    implementation 'androidx.appcompat:appcompat:1.2.0'
    implementation 'androidx.constraintlayout:constraintlayout:2.0.1'
    implementation 'androidx.vectordrawable:vectordrawable:1.1.0'
    implementation "androidx.cardview:cardview:1.0.0"
    implementation "androidx.media:media:1.1.0"




    //GCS begin
    implementation 'com.google.cloud:google-cloud-storage:1.113.1'
    //GCS end
    
    //implementation 'com.android.support:support-annotations:28.0.0'
    implementation 'com.google.android.gms:play-services-ads:19.4.0'
    implementation 'com.firebaseui:firebase-ui-auth:4.3.0'
    implementation 'com.firebaseui:firebase-ui-firestore:5.1.0'
     implementation 'com.google.firebase:firebase-storage:19.2.0'
    implementation 'com.google.firebase:firebase-firestore:21.6.0'
    implementation 'com.google.firebase:firebase-auth:19.4.0'



 

//toast
    implementation 'com.sdsmdg.tastytoast:tastytoast:0.1.1'
    //progress bar


    annotationProcessor 'com.google.auto.value:auto-value:1.5.1'
   

}

apply plugin: 'com.google.gms.google-services'

i tried to exclude groups like this but didn't help

implementation ('com.google.apis:google-api-services-translate:v2-rev47-1.22.0') {
            exclude group: 'com.google.guava'
        }
        implementation ('com.google.cloud:google-cloud-translate:0.5.0') {
            exclude group: 'io.grpc', module: 'grpc-all'
            exclude group: 'com.google.protobuf', module: 'protobuf-java'
            exclude group: 'com.google.api-client', module: 'google-api-client-appengine'
            exclude group: 'com.google.api.Advice', module: 'jetified-proto-google-common-protos'
        }

and i tried this

 android {
        packagingOptions {
            exclude 'META-INF/DEPENDENCIES'
            exclude 'META-INF/INDEX.LIST'
            exclude 'google/protobuf/field_mask.proto'
            exclude 'google/protobuf/type.proto'
            exclude 'google/protobuf/api.proto'
            exclude 'google/protobuf/empty.proto'
            exclude 'google/protobuf/source_context.proto'
            exclude 'google/protobuf/wrappers.proto'
            exclude 'google/protobuf/struct.proto'
            exclude 'google/protobuf/any.proto'
            exclude 'google/protobuf/timestamp.proto'
            exclude 'google/protobuf/AbstractMessageLite'
            exclude 'google/protobuf/WireFormat'
            exclude 'google/protobuf/WrappersProto'
            exclude 'google/protobuf/Writer'
            
            exclude 'google/api/Advice'
            exclude 'google/api/AdviceOrBuilder'
             
        }

    }

i checked all already available answers but didn't get solution.

if i remove implementation 'com.google.cloud:google-cloud-storage:1.113.1' every thing works normal.

but i need to add cloud storage implementation into my android app to store images.

thanks in adavance

答案1

得分: 3

这些 packagingOptions 相当无用,应予以移除。

问题不在于 GCS,而在于 com.google.api.grpc:proto-google-common-protos

排除操作可能如下所示:

implementation ("com.google.cloud:google-cloud-storage:1.113.1") {
    exclude group: "com.google.api.grpc", module: "proto-google-common-protos"
}

运行 ./gradlew app:dependencies > dependencies.txt 以获取依赖树。

英文:

These packagingOptions are rather useless and should be removed.

The issue isn't GCS, but rather com.google.api.grpc:proto-google-common-protos.

An exclusion might look alike this:

implementation ("com.google.cloud:google-cloud-storage:1.113.1") {
    exclude group: "com.google.api.grpc", module: "proto-google-common-protos"
}

Run ./gradlew app:dependencies > dependencies.txt to get the dependency tree.

huangapple
  • 本文由 发表于 2020年9月23日 19:11:04
  • 转载请务必保留本文链接:https://go.coder-hub.com/64026660.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定