【问题标题】:No Cache available for version "com.google.android.gms:play-services:11.8.0"没有适用于版本“com.google.android.gms:play-services:11.8.0”的缓存
【发布时间】:2017-12-25 05:38:42
【问题描述】:

在我的 android 应用程序中使用谷歌地图活动时,我收到此错误。

“无法解析 com.google.android.gms:play-services:11.8.0。”

项目级别 Gradle 文件:

buildscript {

repositories {
    jcenter()
    google()
}
dependencies {
    classpath 'com.android.tools.build:gradle:3.0.1'

    // NOTE: Do not place your application dependencies here; they belong
    // in the individual module build.gradle files
}
}
allprojects {
    repositories {
        jcenter()
        google()
    }
}
task clean(type: Delete) {
    delete rootProject.buildDir
}

应用程序级别 Gradle 文件:

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.constraint:constraint-layout:1.0.2'
    testCompile 'junit:junit:4.12'
    //noinspection GradleCompatible
    implementation 'com.android.support:appcompat-v7:26.1.0'
    implementation 'com.google.android.gms:play-services:11.8.0'
}

【问题讨论】:

  • 检查您是否还在 Android SDK 管理器的 Extras 下安装了“Google Repository”。
  • 是的,我已经安装了。
  • 我在尝试从 Android Studio 构建项目时遇到了同样的问题。请尝试从控制台构建它。然后,当所有依赖项都下载完毕后,切换回 android studio

标签: android google-maps android-gradle-plugin google-play-services build.gradle


【解决方案1】:

所以,我终于得到了答案,

我已打开 gradle 离线模式,这就是为什么它无法找到该版本播放服务的缓存文件的原因。

我将其关闭(在 File-Settings-Build、Execution、Deployment-Gradle 下)并再次同步项目并下载了一些文件,然后它现在可以工作了。

【讨论】:

    【解决方案2】:

    您需要在项目级别 gradle 中包含此 类路径

    classpath 'com.google.gms:google-services:3.0.0'
    

    以及内部应用级别build.gradle

    apply plugin: 'com.google.gms.google-services'
    

    【讨论】:

    • 错误:未找到 ID 为“com.google.gms.google-services”的插件。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-06-20
    • 1970-01-01
    • 2018-11-18
    • 2018-06-29
    • 2020-03-10
    • 2018-10-22
    相关资源
    最近更新 更多