【问题标题】:Duplicate class (com.google.android.gms:play-services-places:9.6.1)重复类(com.google.android.gms:play-services-places:9.6.1)
【发布时间】:2019-08-04 22:44:54
【问题描述】:

我想知道如何解决重复依赖的错误。 我没有库版本 9.6.1。它来自哪里?

这是我的build.gradle 文件

apply plugin: 'com.android.application'

android {
    compileSdkVersion 28
    defaultConfig {
        applicationId "com.example.g_track"
        minSdkVersion 20
        targetSdkVersion 28
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
        multiDexEnabled true

    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        }
    }
}

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


    implementation 'com.google.android.gms:play-services-location:17.0.0'
    //noinspection GradleCompatible
    implementation 'androidx.appcompat:appcompat:1.0.0'


    implementation 'androidx.multidex:multidex:2.0.0'

    implementation 'com.google.android.material:material:1.0.0'
    implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
    implementation 'androidx.legacy:legacy-support-v4:1.0.0'
    implementation 'com.google.firebase:firebase-database:16.0.5'

    implementation 'com.google.android.gms:play-services-maps:16.1.0'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'androidx.test:runner:1.1.0'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.0'
    implementation 'de.hdodenhof:circleimageview:3.0.0'
    implementation 'com.github.ar-android:DrawRouteMaps:1.0.0'
    implementation 'com.github.jd-alexander:library:1.1.0'
    implementation 'com.cs:googlemaproute:1.0.0'
    implementation 'androidx.recyclerview:recyclerview:1.0.0'
    implementation 'androidx.cardview:cardview:1.0.0'
    implementation 'androidx.annotation:annotation:1.0.0'
    implementation 'org.jetbrains:annotations-java5:15.0'


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

它给了我这个错误。我不要com.google.android.gms:play-services-places:9.6.1

在模块 classes.jar (com.google.android.gms:play-services-places-placereport:17.0.0) 和 classes.jar ( com.google.android.gms:play-services-places:9.6.1)

转到文档以了解如何修复依赖项解析错误。

【问题讨论】:

  • 可能是因为使用了'com.google.android.gms:play-services-location:17.0.0''com.google.android.gms:play-services-maps:16.1.0'。尝试 16 或 17 两者
  • @Psycho 我试过但同样的错误。

标签: java android libraries


【解决方案1】:

问题在于implementation 'com.cs:googlemaproute:1.0.0' 依赖项背后,它使用com.google.android.gms:play-services:9.0.2 作为其依赖项之一。要告诉 Gradle 忽略 googlemaproute 使用的第二个依赖项并使用您的依赖项,您必须将其从您的 3rd 方库中排除。

所以使用:

implementation ('com.cs:googlemaproute:1.0.0') {
    exclude group: "com.google.android.gms" 
}

而不是

implementation 'com.cs:googlemaproute:1.0.0'

【讨论】:

  • 每当我添加任何版本的实现 'com.google.android.gms:play-services-location:x.x.x' 时都会显示此错误。如果我删除此依赖项,它将正常工作。我想获取设备的位置,但由于这个错误我不能。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2016-10-02
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多