Ngu*_*Đạt 2 android google-maps android-support-library google-play-services android-gradle-plugin
我想获取设备的当前位置,我点击此链接:google
本教程需要 Google Play 服务版本 11.2.0 或更高版本。但是当我编译' com.google.android.gms:play-services:11.2.0'时,我得到:
Error:(26, 13) Failed to resolve: com.android.support:appcompat-v7:26.0.0
Run Code Online (Sandbox Code Playgroud)
这是我的 build.gradle(Module:app):
apply plugin: 'com.android.application'
android {
compileSdkVersion 26
buildToolsVersion "26.0.1"
defaultConfig {
applicationId "com.example.administrator.googlemap"
minSdkVersion 15
targetSdkVersion 26
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
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:26.+'
compile 'com.google.android.gms:play-services:11.2.0'
compile 'com.google.android.gms:play-services-maps:11.0.2'
compile 'com.google.android.gms:play-services-places:11.0.2'
compile 'com.google.android.gms:play-services-location:11.0.2'
testCompile 'junit:junit:4.12'
}
Run Code Online (Sandbox Code Playgroud)
这是我的 build.grandle(项目)
buildscript {
repositories {
jcenter()
maven { url "https://maven.google.com/"}
}
dependencies {
classpath 'com.android.tools.build:gradle:2.3.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
}
Run Code Online (Sandbox Code Playgroud)
我该如何解决这个错误?
而不是变量版本名称
compile 'com.android.support:appcompat-v7:26.+'
Run Code Online (Sandbox Code Playgroud)
使用恒定版本,最新的是26.1.0
compile 'com.android.support:appcompat-v7:26.1.0'
Run Code Online (Sandbox Code Playgroud)
您在 buildscript 存储库列表中有 google maven repo 链接,您还应该在根文件的项目依赖项存储库列表中添加 google maven build.gradlerepo
allprojects {
repositories {
jcenter()
maven { url "https://maven.google.com/"}
}
}
Run Code Online (Sandbox Code Playgroud)
选择性编译是比完整play-services工件更好的选择,您应该选择项目中需要的内容。
compile 'com.google.android.gms:play-services:11.2.0' // -> latest is 11.4.0
Run Code Online (Sandbox Code Playgroud)
将其分解为您所需的工件,例如
compile 'com.google.android.gms:play-services-maps:11.4.0'
compile 'com.google.android.gms:play-services-places:11.4.0'
compile 'com.google.android.gms:play-services-location:11.4.0'
Run Code Online (Sandbox Code Playgroud)
如果您使用 Gradle 3.0.0 或更高版本的 Android 插件
repositories {
mavenLocal()
mavenCentral()
google() //---> Add this
}
Run Code Online (Sandbox Code Playgroud)
替换compile为implementation,有关此替换的更多信息请参见此处
| 归档时间: |
|
| 查看次数: |
24335 次 |
| 最近记录: |