java - 当我尝试将 google 地点库添加到我的项目时出现问题

标签 java android android-studio build.gradle google-places

对不起我的英语...好吧,让我们走吧,当我添加谷歌位置库的依赖项并同步它的所有内容时,一切正常,但直到我构建,显示重复的类错误我尝试添加注释处理器,但它没有工作...我希望有一些帮助,谢谢。

图书馆:实现“com.google.android.libraries.places:places:1.1.0”

尝试解决实现此依赖项

    annotationProcessor 'com.google.auto.value:auto-value:1.6.2'
    implementation 'com.google.auto.value:auto-value-annotations:1.6.2'

并升级依赖但不幸

    implementation 'com.google.auto.value:auto-value:1.6.5'
    implementation 'com.google.auto.value:auto-value-annotations:1.6.5'

我的依赖项

dependencies {
        implementation fileTree(include: ['*.jar'], dir: 'libs')
        //noinspection GradleCompatible

        implementation "com.android.support:appcompat-v7:$supportLibraryVersion"
        implementation "com.android.support:design:$supportLibraryVersion"
        implementation "com.android.support:support-v4:$supportLibraryVersion"
        implementation "com.android.support:palette-v7:$supportLibraryVersion"
        implementation 'com.android.support.constraint:constraint-layout:1.1.3'

        //annotationProcessor 'com.google.auto.value:auto-value:1.6.2'
        //implementation 'com.google.auto.value:auto-value-annotations:1.6.2'
        //implementation 'com.google.auto.value:auto-value:1.6.5'
        //implementation 'com.google.auto.value:auto-value-annotations:1.6.5'
        //annotationProcessor 'com.google.auto.value:auto-value-compiler:1.6.5'

        implementation 'com.google.android.libraries.places:places:1.1.0'

        implementation 'com.github.bumptech.glide:glide:4.9.0'

        annotationProcessor 'com.github.bumptech.glide:compiler:4.9.0'

        implementation 'com.google.firebase:firebase-core:16.0.4'
        implementation 'com.google.firebase:firebase-messaging:17.3.4'
        implementation 'com.google.firebase:firebase-auth:16.0.5'
        implementation 'com.google.firebase:firebase-database:16.0.5'
        implementation 'com.google.firebase:firebase-storage:15.0.2'
        implementation 'com.google.firebase:firebase-ads:17.0.0'
        implementation 'com.google.firebase:firebase-functions:16.1.1'
        implementation 'com.firebaseui:firebase-ui-auth:4.3.2'
        implementation 'com.google.android.gms:play-services-maps:16.1.0'
        implementation 'com.google.android.gms:play-services-location:16.0.0'
        implementation 'de.hdodenhof:circleimageview:2.2.0'
        implementation 'com.zhihu.android:matisse:0.5.2-beta3'
        implementation 'com.github.chrisbanes:PhotoView:2.1.4'
        implementation 'com.github.hani-momanii:SuperNova-Emoji:1.1'
        implementation 'com.kailashdabhi:om-recorder:1.1.5'
        implementation 'com.github.lzyzsd:circleprogress:1.2.1'
        implementation 'com.github.codekidX:storage-chooser:2.0.4.2'
        implementation 'com.fxn769:musicwave:1.0'
        implementation 'ca.barrenechea.header-decor:header-decor:0.2.8'
        implementation 'com.thoughtbot:expandablecheckrecyclerview:1.4'
        implementation 'com.devlomi.record-view:record-view:2.0.1'
        implementation 'io.realm:android-adapters:3.1.0'
        implementation 'com.devlomi.hidely:hidely:1.0.0'
        implementation 'com.github.broakenmedia:MultiContactPicker:1.8.5'
        implementation 'me.leolin:ShortcutBadger:1.1.22@aar'
        implementation 'com.theartofdev.edmodo:android-image-cropper:2.7.0'
        implementation 'com.github.ozodrukh:CircularReveal:1.1.0'
        implementation 'com.github.oxoooo:pull-back-layout:1.0.1'
        implementation 'io.michaelrocks:libphonenumber-android:8.4.1'
        implementation 'org.greenrobot:eventbus:3.0.0'
        implementation 'com.googlecode.ez-vcard:ez-vcard:0.10.3'
        implementation 'com.android.support:multidex:1.0.3'
        implementation 'me.zhanghai.android.systemuihelper:library:1.0.0'
        implementation 'com.evernote:android-job:1.2.6'
        implementation 'com.devlomi:circularstatusview:1.0.1'
        implementation 'com.android.support:support-v4:28.0.0'
        testImplementation 'junit:junit:4.12'
        implementation project(path: ':cameraView')
        implementation project(path: ':stories-progress-view')
        implementation(name: 'sinch-android-rtc-3.12.8', version: '3.12.8', ext: 'aar')
        implementation 'com.txusballesteros:AutoscaleEditText:1.0'
        implementation('com.google.cloud:google-cloud-translate:1.12.0') {
            exclude group: 'org.apache.httpcomponents'
            exclude group: 'org.json', module: 'json'
        }
        annotationProcessor 'com.google.cloud:google-cloud-translate:1.12.0'
        implementation 'com.android.support:recyclerview-v7:28.0.0'
    }

    repositories {
        mavenCentral()
        flatDir {
            dirs 'libs'
        }
    }

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

错误

Duplicate class com.google.auto.value.AutoAnnotation found in modules auto-value-1.2.jar (com.google.auto.value:auto-value:1.2) and auto-value-annotations-1.6.2.jar (com.google.auto.value:auto-value-annotations:1.6.2)
Duplicate class com.google.auto.value.AutoValue found in modules auto-value-1.2.jar (com.google.auto.value:auto-value:1.2) and auto-value-annotations-1.6.2.jar (com.google.auto.value:auto-value-annotations:1.6.2)
Duplicate class com.google.auto.value.AutoValue$Builder found in modules auto-value-1.2.jar (com.google.auto.value:auto-value:1.2) and auto-value-annotations-1.6.2.jar (com.google.auto.value:auto-value-annotations:1.6.2)

Go to the documentation to learn how to Fix dependency resolution errors.

最佳答案

我解决了错误,通过 gradle 执行依赖项任务以查看所有依赖项树。 它显示所有依赖项和子依赖项帮助我找到正在使用的其他依赖项(com.google.auto.value:auto-value:1.2),并且我在google tannslate dependencyecy中发现了问题,因此仅从('com.google.auto.value:auto-value:1.2)中排除。 google.cloud:google-cloud-translate:1.12.0') 重复的依赖项。

这样就是谷歌翻译依赖项:

implementation('com.google.cloud:google-cloud-translate:1.12.0') {
    exclude group: 'org.apache.httpcomponents'
    exclude group: 'org.json', module: 'json'
    exclude group: 'com.google.auto.value', module: 'auto-value'
}

希望可以帮助其他有相同或类似问题的人

关于java - 当我尝试将 google 地点库添加到我的项目时出现问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57191551/

相关文章:

android - 如何注册与 MP3 的新文件类型关联

java - 如何更改 ListView 项目数?

java - 如何根据用户的需要创建尽可能多的对象?

java - 这段代码是否正确使用了 ReentrantReadWriteLock?

android - 如何使用 SUPPLICANT_STATE_CHANGED_ACTION WiFi BroadcastReceiver - android

c# - 如何在 Android 设备上访问/读取/写入内部存储中的文档文件夹?

android-studio - Android Studio 应用程序中的谷歌字体?

java - Hibernate:无法通过 com.mahlzeit.datamodel.address.City.id 的反射 setter 设置字段值

java - 如何使用上次关闭的设置启动应用程序?

android - 在 Android Studio 中更改布局后需要清理项目