android - 错误 :(23, 13) 无法解析 : com. google.android.gms :play-services:11. 2.0 "Install Repository and sync project"不起作用

标签 android android-gradle-plugin google-play-services

我正在尝试在我的 Android 应用程序中获取位置并更新到服务器。 这是我的 Gradle 代码,这里我包含了 compile 'com.google.android.gms:play-services:11.2.0'。这一行是from the documentation :

dependencies {
    compile 'com.google.android.gms:play-services:11.2.0'

    compile 'com.android.support:appcompat-v7:25.3.1'
    compile 'com.android.support:design:25.3.1'
    compile 'com.android.support.constraint:constraint-layout:1.0.2'
    compile 'com.android.support:support-v4:25.3.1'       
}

但这是我得到的错误:

Error:(23, 13) Failed to resolve: com.google.android.gms:play-services:11.2.0
Install Repository and sync project
Show in File
Show in Project Structure dialog

单击“安装存储库和同步项目”不起作用。

最佳答案

将此添加到您的项目级 build.gradle 文件中:

repositories {
    maven {
        url "https://maven.google.com"
    }
}

关于android - 错误 :(23, 13) 无法解析 : com. google.android.gms :play-services:11. 2.0 "Install Repository and sync project"不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45688654/

相关文章:

java - 为什么 CountdownTimer 只调用 onTick 一次?

android - 将非常大的文本设置为 EditText

android - 从网站下载 APK 并提示用户安装

java - 新更新后整合 Google Play 游戏服务

android - 在 Android 中获取屏幕尺寸

android - 点击后退按钮时将数据保存在编辑文本中

gradle - 如何在 Gradle 上检查 buildscript 插件的版本?

android - build.gradle:有条件地在产品变体中包含功能

android - 升级 Android Gradle 插件 7.1 后无法加载类 AndroidComponentsExtension

android - org.gradle.internal.resolve.ArtifactNotFoundException : Could not find play-services-basement. aar