【问题标题】:while implementing GCS, Duplicate class found error after adding implementation 'com.google.cloud:google-cloud-storage' in gradle android在实现 GCS 时,在 gradle android 中添加实现 'com.google.cloud:google-cloud-storage' 后,重复类发现错误
【发布时间】:2021-01-09 13:52:54
【问题描述】:

当我在 gradle 中将 Google 云存储实现添加到我现有的 android 应用程序时 (实施 'com.google.cloud:google-cloud-storage:1.113.1'), 我收到这些依赖错误

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

像这样我得到了 100 行请帮忙 这是我的 build.gradle 文件

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'

我尝试排除此类群组,但没有帮助

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 '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'
             
        }

    }

我检查了所有可用的答案,但没有得到解决方案。

如果我删除实施 'com.google.cloud:google-cloud-storage:1.113.1' 一切正常。

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

提前感谢

【问题讨论】:

    标签: java android google-cloud-platform google-cloud-storage build.gradle


    【解决方案1】:

    这些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获取依赖树。

    【讨论】:

      猜你喜欢
      • 2021-09-14
      • 2017-04-08
      • 1970-01-01
      • 2023-01-29
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-07-12
      相关资源
      最近更新 更多