我想将位置 API 与 Google Play 服务一起使用
这是顶级 gradle 文件:
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.2.3'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
这是我的应用级 gradle 文件:
apply plugin: 'com.android.application'
android {
compileSdkVersion 25
buildToolsVersion "25.0.1"
defaultConfig {
applicationId "..."
minSdkVersion 14
targetSdkVersion 25
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
productFlavors {
}
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
// androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
// exclude group: 'com.android.support', module: 'support-annotations'
// })
compile 'com.android.support:appcompat-v7:25.0.1'
compile 'com.android.support:design:25.0.1'
compile 'com.android.support:recyclerview-v7:25.0.1'
compile 'com.google.android.gms:play-services:11.4.2'
}
当我想构建项目时,显示此错误:
Error:(30, 13) Failed to resolve: com.google.android.gms:play-services:11.4.2
Install Repository and sync project
Show in File
Show in Project Structure dialog
我已经通过单击“安装存储库和同步项目”安装了 Google Play 服务,但仍然显示错误
根据此文档: https://developers.google.com/android/guides/setup 我已将 google-play-services 依赖项替换为以下行:
compile 'com.google.android.gms:play-services-location:11.4.2'
compile 'com.google.android.gms:play-services-maps:11.4.2'
当我构建项目时,显示“无法解决...”错误,但是当我单击“安装存储库并同步项目”时,什么也没发生!
问题是什么 ?版本号有问题?或者是其他东西 ?!