首页 > 解决方案 > 如何在使用 Google Places SDK 时克服重复类问题

问题描述

我正在将我的 Android 应用程序从旧版本的 Places SDK 转换为新版本,因为旧版本将于 7 月 29 日停用。我按照文档的建议进行了更改。

在编译时,我从我自己的代码中明显不使用它的类中看到大量重复的类错误消息。尽管它们可以在图书馆中使用。

Duplicate class com.bumptech.glide.GeneratedAppGlideModule found in modules classes.jar (com.github.bumptech.glide:glide:4.3.1) and glide-4.3.1.jar (com.github.bumptech.glide:glide:4.3.1)
Duplicate class com.bumptech.glide.GenericTransitionOptions found in modules classes.jar (com.github.bumptech.glide:glide:4.3.1) and glide-4.3.1.jar (com.github.bumptech.glide:glide:4.3.1)
Duplicate class com.bumptech.glide.Glide found in modules classes.jar (com.github.bumptech.glide:glide:4.3.1) and glide-4.3.1.jar (com.github.bumptech.glide:glide:4.3.1)
Duplicate class com.bumptech.glide.GlideBuilder found in modules classes.jar (com.github.bumptech.glide:glide:4.3.1) and glide-4.3.1.jar (com.github.bumptech.glide:glide:4.3.1)
Duplicate class com.bumptech.glide.GlideBuilder$1 found in modules classes.jar (com.github.bumptech.glide:glide:4.3.1) and glide-4.3.1.jar (com.github.bumptech.glide:glide:4.3.1)
Duplicate class com.bumptech.glide.GlideContext found in modules classes.jar (com.github.bumptech.glide:glide:4.3.1) and glide-4.3.1.jar (com.github.bumptech.glide:glide:4.3.1)
Duplicate class com.bumptech.glide.ListPreloader found in modules classes.jar (com.github.bumptech.glide:glide:4.3.1) and glide-4.3.1.jar (com.github.bumptech.glide:glide:4.3.1)
Duplicate class com.bumptech.glide.ListPreloader$PreloadModelProvider found in modules classes.jar (com.github.bumptech.glide:glide:4.3.1) and glide-4.3.1.jar (com.github.bumptech.glide:glide:4.3.1)
Duplicate class com.bumptech.glide.ListPreloader$PreloadSizeProvider found in modules classes.jar (com.github.bumptech.glide:glide:4.3.1) and glide-4.3.1.jar (com.github.bumptech.glide:glide:4.3.1)
Duplicate class com.bumptech.glide.ListPreloader$PreloadTarget found in modules classes.jar (com.github.bumptech.glide:glide:4.3.1) and glide-4.3.1.jar (com.github.bumptech.glide:glide:4.3.1)
Duplicate class com.bumptech.glide.ListPreloader$PreloadTargetQueue found in modules classes.jar (com.github.bumptech.glide:glide:4.3.1) and glide-4.3.1.jar (com.github.bumptech.glide:glide:4.3.1)
Duplicate class com.bumptech.glide.MemoryCategory found in modules classes.jar (com.github.bumptech.glide:glide:4.3.1) and glide-4.3.1.jar (com.github.bumptech.glide:glide:4.3.1)
Duplicate class com.bumptech.glide.Priority found in modules classes.jar (com.github.bumptech.glide:glide:4.3.1) and glide-4.3.1.jar (com.github.bumptech.glide:glide:4.3.1)
Duplicate class com.bumptech.glide.Registry found in modules classes.jar (com.github.bumptech.glide:glide:4.3.1) and glide-4.3.1.jar (com.github.bumptech.glide:glide:4.3.1)
Duplicate class com.bumptech.glide.Registry$MissingComponentException found in modules classes.jar (com.github.bumptech.glide:glide:4.3.1) and glide-4.3.1.jar (com.github.bumptech.glide:glide:4.3.1)
Duplicate class com.bumptech.glide.Registry$NoImageHeaderParserException found in modules classes.jar (com.github.bumptech.glide:glide:4.3.1) and glide-4.3.1.jar (com.github.bumptech.glide:glide:4.3.1)
Duplicate class com.bumptech.glide.Registry$NoModelLoaderAvailableException found in modules classes.jar (com.github.bumptech.glide:glide:4.3.1) and glide-4.3.1.jar (com.github.bumptech.glide:glide:4.3.1)
Duplicate class com.bumptech.glide.Registry$NoResultEncoderAvailableException found in modules classes.jar (com.github.bumptech.glide:glide:4.3.1) and glide-4.3.1.jar (com.github.bumptech.glide:glide:4.3.1)
Duplicate class com.bumptech.glide.Registry$NoSourceEncoderAvailableException found in modules classes.jar (com.github.bumptech.glide:glide:4.3.1) and glide-4.3.1.jar (com.github.bumptech.glide:glide:4.3.1)
Duplicate class com.bumptech.glide.RequestBuilder found in modules classes.jar (com.github.bumptech.glide:glide:4.3.1) and glide-4.3.1.jar (com.github.bumptech.glide:glide:4.3.1)
Duplicate class com.bumptech.glide.RequestBuilder$1 found in modules classes.jar (com.github.bumptech.glide:glide:4.3.1) and glide-4.3.1.jar (com.github.bumptech.glide:glide:4.3.1)
Duplicate class com.bumptech.glide.RequestBuilder$2 found in modules classes.jar (com.github.bumptech.glide:glide:4.3.1) and glide-4.3.1.jar (com.github.bumptech.glide:glide:4.3.1)
Duplicate class com.bumptech.glide.RequestManager found in modules classes.jar (com.github.bumptech.glide:glide:4.3.1) and glide-4.3.1.jar (com.github.bumptech.glide:glide:4.3.1)

我遇到了 repo 的问题页面,但没有看到有价值的更新

https://github.com/bumptech/glide/issues/3527

这是我的 build.gradle

应用插件:'com.android.application'

android {
compileSdkVersion 26
defaultConfig {
    applicationId "com.xxxxx.xxxxxx"
    minSdkVersion 16
    targetSdkVersion 26
    versionCode 28
    versionName '3.7'
    multiDexEnabled true
    testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
    release {
        minifyEnabled false
        lintOptions {
            disable 'MissingTranslation'
            checkReleaseBuilds false
            abortOnError false

        }
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
    }
}

packagingOptions {
    pickFirst 'META-INF/LICENSE.txt' // picks the JavaMail license file
}
productFlavors {
}

}buildscript {
repositories {
    maven {
        url "https://maven.java.net/content/groups/public/"
    }
}
}

dependencies {



implementation fileTree(include: ['*.jar'], dir: 'libs')
//noinspection GradleCompatible
implementation 'com.android.support:appcompat-v7:26.1.0'
implementation 'com.android.support:support-v4:26.1.0'


implementation 'com.ramotion.foldingcell:folding-cell:1.2.2'
implementation 'com.sun.mail:android-mail:1.5.5'
implementation 'com.sun.mail:android-activation:1.5.5'
//implementation 'com.google.android.gms:play-services-places:15.0.1'
implementation 'com.google.android.gms:play-services-location:15.0.1'


implementation 'com.android.support:design:26.1.0'
implementation 'com.android.support:cardview-v7:26.1.0'
implementation 'com.android.support:recyclerview-v7:26.1.0'


implementation 'com.squareup.retrofit2:retrofit:2.3.0'
implementation 'com.squareup.okhttp3:logging-interceptor:3.9.0'
implementation 'com.squareup.retrofit2:converter-gson:2.3.0'
implementation 'com.wdullaer:materialdatetimepicker:3.5.1'
implementation 'com.applandeo:material-calendar-view:1.4.0'
implementation 'com.squareup.picasso:picasso:2.71828'
implementation 'gun0912.ted:tedpermission:2.1.0'

implementation 'com.android.support.constraint:constraint-layout:1.1.2'
implementation 'com.google.firebase:firebase-crash:16.0.1'
implementation 'com.google.firebase:firebase-messaging:17.3.2'
implementation 'com.google.firebase:firebase-core:16.0.1'


implementation 'com.github.chrisbanes:PhotoView:2.1.0'
implementation 'commons-lang:commons-lang:2.6'
implementation 'org.jsoup:jsoup:1.10.1'
implementation 'com.google.android.libraries.places:places:1.1.0'

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

我试图排除使用 gradle 编译的类,但我似乎在这里做错了(虽然对 Gradle 来说很新)。

configurations {

    compile.exclude group: 'com.bumptech.glide' , module: 'glide'

}

这个片段可以排除那些正在编译的类吗?我可以将它们添加到应用程序的 build.gradle 中吗?

非常感谢您的意见。非常感激

标签: androidgradle

解决方案


推荐阅读