如何修复 android studio 中与 android.gms:play-services:12.0.1 相关的依赖项解析错误

How to fix Dependency resolution Error in android studio related to android.gms:play-services:12.0.1

在我将 play-services:12.0.1 实施到我的应用程序模块之前,一切都很完美。尝试更改播放服务的版本但没有任何帮助。在实施之前,它运行良好。

dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'androidx.appcompat:appcompat:1.0.2'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
implementation 'com.google.firebase:firebase-database:18.0.1'
implementation 'com.google.android.gms:play-services-maps:16.1.0'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test:runner:1.2.0'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
implementation 'com.google.firebase:firebase-core:17.0.0'
implementation 'com.google.firebase:firebase-auth:18.1.0'
implementation 'com.google.firebase:firebase-firestore:20.2.0'
implementation 'com.google.android.gms:play-services:12.0.1' }

错误如下:

Duplicate class com.google.android.gms.measurement.AppMeasurement found in modules classes.jar (com.google.android.gms:play-services-measurement-impl:17.0.0) and classes.jar (com.google.firebase:firebase-analytics-impl:12.0.1)

错误行较多。我想 firebase

存在某种问题

删除这一行:

implementation 'com.google.android.gms:play-services:12.0.1'

并添加您需要的单个模块。在你的情况下:

implementation 'com.google.android.gms:play-services-location:17.0.0'

你也应该更新(为了 androidx 兼容性)

implementation 'com.google.android.gms:play-services-maps:16.1.0'

implementation 'com.google.android.gms:play-services-maps:17.0.0'