当我尝试将谷歌地方库添加到我的项目时出现问题

Posted

技术标签:

【中文标题】当我尝试将谷歌地方库添加到我的项目时出现问题【英文标题】:problems when i try to add google places library to my project 【发布时间】:2019-12-03 02:48:38 【问题描述】:

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

图书馆:实施 '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.

【问题讨论】:

【参考方案1】:

我解决了错误,通过 gradle 执行依赖任务以查看所有依赖树。 它显示所有依赖项和子依赖项帮助我找到其他依赖项正在使用(com.google.auto.value:auto-value:1.2),我在 google tannslate 依赖项中发现了问题,因此仅从 ('com. 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'

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

【讨论】:

【参考方案2】:

在你的 gradle(app) 中添加这个

configurations.all 
    resolutionStrategy 
        force("com.google.auto.value:auto-value:1.6.3")
    

【讨论】:

以上是关于当我尝试将谷歌地方库添加到我的项目时出现问题的主要内容,如果未能解决你的问题,请参考以下文章

如何将谷歌键盘(Gboard)添加到我自己的 android studio 项目中?

当我尝试将 TapGestureRecognizer 添加到我的 UIImageView 时出现此错误:Unrecognized selector sent to class

当我尝试与我的数据库建立连接时出现错误

如何将谷歌地图添加到android

有没有一种简单的方法可以将谷歌登录按钮添加到 HTML 文件?

尝试添加现有类模块时出现内存不足错误 VB6