我试图将我的Pl​​aces SDK迁移到新的Place sdk。但是在放置所有必需的依赖项之后,IDE会报告依赖项错误。

这些是错误

Duplicate class com.google.android.libraries.places.widget.AutocompleteActivity found in modules classes.jar (com.google.android.libraries.places:places-compat:2.0.0) and classes.jar (com.google.android.libraries.places:places:2.0.0)Duplicate class com.google.android.libraries.places.widget.zza found in modules classes.jar (com.google.android.libraries.places:places-compat:2.0.0) and classes.jar (com.google.android.libraries.places:places:2.0.0)Duplicate class com.google.android.libraries.places.widget.zzb found in modules classes.jar (com.google.android.libraries.places:places-compat:2.0.0) and classes.jar (com.google.android.libraries.places:places:2.0.0)Duplicate class com.google.android.libraries.places.widget.zzc found in modules classes.jar (com.google.android.libraries.places:places-compat:2.0.0) and classes.jar (com.google.android.libraries.places:places:2.0.0)Duplicate class com.google.android.libraries.places.widget.zzd found in modules classes.jar (com.google.android.libraries.places:places-compat:2.0.0) and classes.jar (com.google.android.libraries.places:places:2.0.0)

这是我的依赖

dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'androidx.appcompat:appcompat:1.1.0'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
implementation 'com.google.android.material:material:1.0.0'
implementation 'com.google.android.gms:play-services-maps:17.0.0'
implementation 'com.google.firebase:firebase-analytics:17.2.0'
implementation 'com.google.firebase:firebase-database:19.0.0'
implementation 'com.google.firebase:firebase-core:17.2.0'
implementation 'com.firebase:geofire-java:3.0.0'
//noinspection GradleCompatible
implementation 'androidx.recyclerview:recyclerview:1.0.0'
implementation 'com.google.android.libraries.places:places-      compat:2.0.0'
implementation 'com.h6ah4i.android.widget.verticalseekbar:verticalseekbar:0.7.2'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test:runner:1.2.0'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
implementation 'com.google.android.gms:play-services-location:17.0.0'
implementation 'com.google.android.libraries.places:places:2.0.0'

}

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

最佳答案

只是删除这种依赖性
implementation 'com.google.android.libraries.places:places:2.0.0'

仅使用'com.google.android.libraries.places:places-compat:2.0.0'问题将得到解决。

关于java - 如何修复Dependency Error Android Studio,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/57895147/

10-12 00:13