谷歌地图API Gradle依赖项无法解析。

3
它向我显示一个解决依赖项失败的错误:
Error:(25, 13) Failed to resolve: com.google.android.gms:play-services-maps:11.4.0

这些是我正在使用的依赖项:

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    testCompile 'junit:junit:4.12'
    compile 'com.android.support:appcompat-v7:23.4.0'
    compile 'com.google.android.gms:play-services-maps:11.4.0'

}

我该怎么办?

2个回答

11

要使用11.4.0,您需要将 maven { url "https://maven.google.com" } 添加到您的 build.gradle 文件中。

allprojects {
    repositories {
        jcenter()
        maven {
            url "https://maven.google.com"
        }
    }
}

尝试过了,但仍然显示错误。 - Hadi Abu
@HadiAbu 请发布您更新后的 build.gradle 文件和错误信息。 - Gabriele Mariotti
它起作用了。 之前我在地图和位置上有两个不同的依赖版本:compile 'com.google.android.gms:play-services-maps:11.4.0' compile 'com.google.android.gms:play-services-location:11.0.4'但是我将它们改成了相同的版本,然后它就起作用了:compile 'com.google.android.gms:play-services-maps:11.4.0' compile 'com.google.android.gms:play-services-location:11.4.0' - Hadi Abu

4
原来Google Maps 库的依赖应该是:
compile 'com.google.android.gms:play-services-maps:11.0.4'

并非

compile 'com.google.android.gms:play-services-maps:11.4.0'

1
这不是你遇到问题的原因。11.4.0版本存在,但需要新的Google Maven仓库。 - Gabriele Mariotti

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接