【问题标题】:Failed to resolve: com.google.android.gms:play-services:9.6.0 when syncing project同步项目时无法解决:com.google.android.gms:play-services:9.6.0
【发布时间】:2016-09-26 16:51:02
【问题描述】:

我正在尝试在我的 Android 应用上使用 Google Play 服务来获取设备的最后一个已知位置,但是当我尝试添加 gradle 依赖项时:

compile 'com.google.android.gms:play-services:9.6.0'

我收到以下错误:

A problem occurred configuring project ':app'. Could not resolve all dependencies for configuration ':app:_debugCompile'. Could not find com.google.android.gms:play-services:9.6.0. Searched in the following locations: https://jcenter.bintray.com/com/google/android/gms/play-services/9.6.0/play-services-9.6.0.pom https://jcenter.bintray.com/com/google/android/gms/play-services/9.6.0/play-services-9.6.0.jar file:/home/user/Android/Sdk/extras/android/m2repository/com/google/android/gms/play-services/9.6.0/play-services-9.6.0.pom file:/home/user/Android/Sdk/extras/android/m2repository/com/google/android/gms/play-services/9.6.0/play-services-9.6.0.jar file:/home/user/Android/Sdk/extras/google/m2repository/com/google/android/gms/play-services/9.6.0/play-services-9.6.0.pom file:/home/user/Android/Sdk/extras/google/m2repository/com/google/android/gms/play-services/9.6.0/play-services-9.6.0.jar

有谁知道如何解决这个问题?谢谢!

编辑

这是我的 build.gradle 文件:

    apply plugin: 'com.android.application'

    android {
        compileSdkVersion 24
        buildToolsVersion "24.0.2"

        defaultConfig {
            applicationId "app"
            minSdkVersion 16
            targetSdkVersion 24
            versionCode 1
            versionName "1.0"
        }


        buildTypes {
            release {
                minifyEnabled false
                proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
            }
        }

        lintOptions {
            abortOnError false
        }
    }

    dependencies {
        compile fileTree(dir: 'libs', include: ['*.jar'])
        testCompile 'junit:junit:4.12'
        compile 'com.android.support:appcompat-v7:24.2.0'
        compile group: 'com.google.code.gson', name: 'gson', version: '2.7'
        compile 'com.squareup.okhttp3:okhttp:3.4.1'
        compile group: 'org.powermock', name: 'powermock-mockito-release-full', version: '1.6.4'
        compile 'org.mockito:mockito-core:1.10.19'
        compile 'com.google.android.gms:play-services:9.6.0'
    }

【问题讨论】:

  • 你能分享你的 gradle 文件吗?

标签: android gradle google-play-services


【解决方案1】:

首先更新您的 SDK 的 Android Support Repository 和 Google Play services。看看之后是否同步。

【讨论】:

  • 如何从命令行执行此操作? (我使用的是 ubuntu 16.04 以防万一)
  • 当我尝试使用 Intellij 构建时,我得到了一个安装存储库的链接,但该链接没有任何作用。
  • 转到您的 android sdk 目录 -> 工具并运行名为 android 的脚本。然后向下滚动并更新上述两个包。
  • 谢谢!这似乎解决了这个问题。 :)
【解决方案2】:

这可能是由于 google play services SDK 未安装在您的 android studio 包中。遵循 Android 开发者指南,了解如何在您的应用程序中设置 google play 服务。里面有一个链接,方便你在包中添加依赖之前如何设置 SDK。
Google Developers Guide : Google Play services setup

【讨论】:

    【解决方案3】:

    在您的项目级 build.gradle 文件中,在 buildscript > 依赖项下, 类路径 'com.google.gms:google-services:3.0.0'

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2019-04-15
      • 1970-01-01
      • 2018-11-23
      • 1970-01-01
      • 2016-10-09
      • 2018-01-04
      • 2017-03-06
      • 1970-01-01
      相关资源
      最近更新 更多