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

Viewed 362

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 Answers

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.

Related