Android依赖项'com.google.android.gms:play-services-base'对于编译(16.0.1)和运行时(16.1.0)类路径具有不同的版本

问题描述 投票:0回答:1

由于不推荐使用Places API,因此在build.gradle中添加以下新的Android Places SDK依赖项后出现错误。

错误

Android依赖项“ com.google.android.gms:play-services-base”具有编译(16.0.1)和运行时(16.1.0)的不同版本类路径。您应该通过以下方式手动设置相同的版本DependencyResolution

我还在项目级别3.2.1中将google服务版本从4.2.0更新为build.gradle

dependencies {
    ...
    classpath "com.google.gms:google-services:4.2.0"
    ...
}

在应用程序级别build.gradle中。我添加了新的Places API依赖关系并评论了旧的依赖关系,我还使用了其他服务,例如项目中的位置和地图,请参见下文

 dependencies {
    ...
    implementation "com.google.android.libraries.places:places:1.0.0" // new
    // implementation "com.google.android.gms:play-services-places:16.0.0" //deprecated
    implementation "com.google.android.gms:play-services-location:16.0.0"
    implementation "com.google.android.gms:play-services-gcm:16.0.0"
    implementation "com.google.android.gms:play-services-maps:16.0.0"
    ...
}
android google-play-services google-places-api
1个回答
0
投票

除了使用依赖关系解析之外,还可以强制Gradle打包特定版本:

implementation("com.google.android.gms:play-services-base:16.1.0") {
    force = true
}
© www.soinside.com 2019 - 2024. All rights reserved.