android - 如何修复错误 :Could not find com. google.gms : google-services: 3. 0.0.?

标签 android firebase android-gradle-plugin

我正在尝试在我的应用中添加 firebase addmob。

在 build.gradle(Project) 中我有以下代码

buildscript {
    repositories {
        jcenter()
    }
    dependencies {
        classpath 'com.google.gms: google-services: 3.0.0'
        classpath 'com.android.tools.build:gradle:2.1.3'

        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

在build.gradle(module)中

apply plugin: 'com.android.application'

android {
    compileSdkVersion 23
    buildToolsVersion "24.0.2"

    defaultConfig {
        applicationId "com.myname.examp.myapp"
        minSdkVersion 14
        targetSdkVersion 23
        versionCode 1
        versionName "1.0"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    testCompile 'junit:junit:4.12'
    compile 'com.android.support:appcompat-v7:23.0.0'
    compile 'com.android.support:design:23.0.0'
    compile 'com.google.firebase: firebase-ads: 9.0.0'
}
apply plugin: 'com.google.gms.google-services'

我更新了 google play 服务和存储库的版本

enter image description here

当我同步项目时仍然出现以下错误

Error:Could not find com.google.gms: google-services: 3.0.0.
Searched in the following locations:
    file:/C:/Program Files/Android/Android Studio2/gradle/m2repository/com/google/gms/ google-services/ 3.0.0/ google-services- 3.0.0.pom
    file:/C:/Program Files/Android/Android Studio2/gradle/m2repository/com/google/gms/ google-services/ 3.0.0/ google-services- 3.0.0.jar
    https://jcenter.bintray.com/com/google/gms/ google-services/ 3.0.0/ google-services- 3.0.0.pom
    https://jcenter.bintray.com/com/google/gms/ google-services/ 3.0.0/ google-services- 3.0.0.jar
Required by:
    :MyApplication:unspecified

谁能帮我解决这个错误

最佳答案

我遇到了类似的问题,我从 firebase 指令中复制了依赖项并粘贴到代码中。

来自说明:

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

应该是:

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

不应包含任何空格。愚蠢但浪费了半个小时。

关于android - 如何修复错误 :Could not find com. google.gms : google-services: 3. 0.0.?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39554608/

相关文章:

firebase - 云构建 : How to execute two CI jobs, 顺序如何?

node.js - 使用带有 GET 的查询字符串在本地测试 Firebase HTTP Cloud 函数

android - 我应该如何在 android studio 中设置 gradle 4.5 的类路径

android - 错误 :(28, 13) 无法解析 : com. squareup.okhttp3 :okhttp:3. 2.0

android - 如何在三星 Galaxy 平板电脑上启动远程调试?

java - Android:工作线程完成工作后如何执行回调

android - 项目的生命周期 - android内存泄漏

android - 错误:java. lang.IllegalArgumentException:空文件名Android

android - 从 firebase android 获取数据时项目终止

android - 无法安装LibGDX [构建工具27.0.2]