我尝试在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'
}
答案 0 :(得分:2)
首先更新您的SDK Android Support Repository
和Google Play services
。看看它是否同步。
答案 1 :(得分:0)
由于谷歌播放服务SDK未安装在您的Android工作室包中,可能会发生这种情况。请遵循Android开发者指南,了解如何在您的应用中设置Google Play服务。在您的包中添加依赖项之前,有一个链接可以帮助您设置SDK Google Developers Guide : Google Play services setup
答案 2 :(得分:0)
在项目级build.gradle文件中,在buildscript>下;依赖关系, classpath'com.google.gms:google-services:3.0.0'