所有 gms 库必须使用与地点和地图完全相同的版本

All gms libraries must use exact same version with places and maps

我的 android google 地图应用程序使用的是 play-service-maps-8.1.0 版本。然后我尝试添加新的 google place service 1.0.0 。现在它给我所有的 gms 库必须是完全相同的版本错误。我在 google 的新服务参考中找不到任何地图服务。

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

none 他们与

合作
implementation 'com.google.android.libraries.places:places:1.0.0'

如何在同一应用程序中使用地点服务和地图服务?

我所有 gradle 依赖项。

dependencies {
    implementation fileTree(include: ['*.jar'], dir: 'libs')
    implementation 'com.android.support:appcompat-v7:26.1.0'
    implementation 'com.android.support.constraint:constraint-layout:1.1.3'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'com.android.support.test:runner:1.0.2'
    androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
    implementation 'com.squareup.okhttp3:okhttp:3.9.1'
    implementation 'com.google.code.gson:gson:2.8.5'
    implementation 'com.android.support:design:26.1.0'

    implementation 'com.google.android.gms:play-services-maps:8.1.0'
    implementation 'com.google.android.libraries.places:places:1.0.0'
}

参见places:1.0.0:它自己拉入play-services-maps:16.0.0 -

places:1.1.0play-services-maps:16.1.0 相同。


您需要将其添加到根项目的 buildscript dependencies:

classpath "com.google.gms:google-services:4.2.0"

这些将是模块的 Java dependencies:

dependencies {
    implementation "com.android.support:design:28.0.0"
    implementation "com.android.support:support-v4:28.0.0"
    implementation "com.android.support:appcompat-v7:28.0.0"
    implementation "com.android.support.constraint:constraint-layout:1.1.3"
    implementation ("com.google.android.libraries.places:places:1.1.0") {
        exclude group: "com.android.support"
    }
    implementation "com.squareup.okhttp3:okhttp:3.12.1"
    implementation "com.google.code.gson:gson:2.8.5"

    testImplementation "junit:junit:4.12"
    androidTestImplementation "com.android.support.test:runner:1.0.2"
    androidTestImplementation "com.android.support.test.espresso:espresso-core:3.0.2"
}

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

对于 Places,没有任何 Firebase 依赖项或 Play 服务插件,您仍然需要至少添加这两个 string 资源(项目仍然需要在 Firebase 上设置,为了获得所需的 google_services.json,其中包含要替换的值):

<?xml version="1.0" encoding="utf-8"?>
<resources>

    <! -- Present in all applications -->
    <string name="google_app_id" translatable="false">YOUR_GOOGLE_APP_ID</string>

    <! -- Present in applications with the appropriate services configured -->
    <string name="google_api_key" translatable="false">YOUR_MAPS_API_KEY</string>

</resources>

参见 documentation