未找到ID为'com.google.gms.google-services'的插件

Lak*_*hmi 69 android admob firebase

我已按照此链接在我的应用中集成广告.但它显示了这个错误:

错误图片

这是我的build.gradle:

apply plugin: 'com.android.application'
apply plugin: 'com.google.gms.google-services'
android {
compileSdkVersion 24
buildToolsVersion "24.0.2"





defaultConfig {
    applicationId "com.example.personal.numbermania"
    minSdkVersion 10
    targetSdkVersion 24
    versionCode 1
    versionName "1.0"
}
buildTypes {
    debug
            {
                debuggable true
            }
    release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
    }
}


dependencies {
    compile fileTree(include: ['*.jar'], dir: 'libs')
    testCompile 'junit:junit:4.12'
    compile 'com.android.support:appcompat-v7:24.2.1'
    compile 'com.android.support:design:24.2.1'
    compile 'com.google.firebase:firebase-ads:9.6.0'

}

}
Run Code Online (Sandbox Code Playgroud)

广告没有出现在真实的设备中.请帮助我这是我更新类路径错误后的 错误

Vas*_*nov 128

有同样的问题.

通过添加依赖项来修复

classpath 'com.google.gms:google-services:3.0.0'
Run Code Online (Sandbox Code Playgroud)

到了 build.gradle.

https://firebase.google.com/docs/android/setup#manually_add_firebase

  • 这些文件还强调了在文件底部以斜体书写“应用插件:'com.google.gms.google-services”的重要性。“在您的模块(应用程序级)Gradle 文件(通常是 app/build.gradle)中,在文件的_底部_添加一行。” (3认同)

Mar*_*ler 83

plugins同时在根目录中设置 Gradle 的build.gradle工作方式如下:

plugins {
    id "com.android.application" version "7.3.1" apply false
    id "com.android.library" version "7.3.1" apply false
    id "com.google.gms.google-services" version "4.3.14" apply false
}
Run Code Online (Sandbox Code Playgroud)

然后它们可以应用在模块中:

plugins {
    id "com.android.application"
    id "com.google.gms.google-services"
}
Run Code Online (Sandbox Code Playgroud)

除非某些 Gradle 插件可能依赖于它,否则可以buildscript完全删除/跳过该块,但它仍然适合在以下位置定义项目范围的版本号buildscript.ext

buildscript {
    ext {
        agp_version = '7.3.1'
        gms_version = '4.3.14'
    }
}

plugins {
    id 'com.android.application' version "$agp_version" apply false
    id 'com.android.library' version "$agp_version" apply false
    id "com.google.gms.google-services" version "$gms_version" apply false
}
Run Code Online (Sandbox Code Playgroud)


era*_*del 41

classpath com.google.gms:google-services:3.0.0 在项目级build.gradle中添加 依赖项

请参阅项目级build.gradle中的示例块

buildscript {
    repositories {
        jcenter()
    }
    dependencies {

        classpath 'com.android.tools.build:gradle:2.3.3'
        classpath 'com.google.gms:google-services:3.0.0'

        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}
Run Code Online (Sandbox Code Playgroud)


Mer*_*rez 22

你可以在这里找到正确的依赖项,将更改应用到app.gradleproject.gradle并告诉我这个,问候!


你的应用插件:"com.google.gms.google服务"app.gradle看起来是这样的:

apply plugin: 'com.android.application'

android {
    compileSdkVersion 24
    buildToolsVersion "24.0.2"

    defaultConfig {
        applicationId "com.example.personal.numbermania"
        minSdkVersion 10
        targetSdkVersion 24
        versionCode 1
        versionName "1.0"

        multiDexEnabled true
    }

    dexOptions {
        incremental true
        javaMaxHeapSize "4g" //Here stablished how many cores you want to use your android studi 4g = 4 cores
    }

    buildTypes {
        debug
                {
                    debuggable true
                }
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

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

apply plugin: 'com.google.gms.google-services'
Run Code Online (Sandbox Code Playgroud)

将classpath添加到项目的gradle:

classpath 'com.google.gms:google-services:3.0.0'
Run Code Online (Sandbox Code Playgroud)

SDK Manager上的Google Play服务库:

在此输入图像描述


小智 18

有同样的问题。

将此添加到我的依赖项并没有解决

类路径 'com.google.gms:google-services:3.0.0'

添加这个为我解决了

类路径 'com.google.gms:google-services:+'

到根 build.gradle。


Ade*_*IMM 11

只需将“classpath 'com.google.gms:google-services:3.0.0'”添加到 android/build.gradle 即可,如下所示

buildscript {
    repositories {
        maven {
            url "https://maven.google.com"
        }
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.0.1'
        classpath 'com.google.gms:google-services:3.0.0'

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

    }
}
Run Code Online (Sandbox Code Playgroud)

并将“应用插件:'com.google.gms.google-services'”添加到 android/app/build.gradle 中的文件末尾,如下所示

apply plugin: 'com.google.gms.google-services'
Run Code Online (Sandbox Code Playgroud)


Edm*_*son 10

升级到 Android Studio 4.2.1 时,系统提示我设置依赖项:

classpath 'com.google.gms:google-services:4.3.7'
Run Code Online (Sandbox Code Playgroud)

但是,这导致“找不到 id 为‘com.google.gms.google-services’的插件”。
保留如下解决了问题:

classpath 'com.google.gms:google-services:4.3.5'
Run Code Online (Sandbox Code Playgroud)

编辑:

此问题现已修复:

classpath 'com.google.gms:google-services:4.3.8'
Run Code Online (Sandbox Code Playgroud)


Kes*_*era 8

Setting > Android SDK > SDK Tools > Google Play Services

在此处输入图片说明


Jam*_*rih 7

我不确定你的情况,但我花了大约 30 分钟来解决同样的问题,直到我意识到 app/build.gradle 的行是:

apply plugin: 'com.google.gms.google-services'
Run Code Online (Sandbox Code Playgroud)

并不是:

apply plugin: 'com.google.gms:google-services'
Run Code Online (Sandbox Code Playgroud)

例如:我从教程中复制了该行,但是在指定应用插件命名空间时,不需要冒号(:)。事实上,它是一个点。( .)。

嘿嘿……很容易错过。


Tai*_*yev 7

Android 设置过程中的 Google 文档不太适合我。谷歌似乎需要更新他们的文档。对我有用的唯一解决方案是:

  1. 作为在 Android 应用程序中启用 Google API 或 Firebase 服务的一部分,您可能需要将 google-services 插件添加到项目级build.gradle文件中。
dependencies {
    classpath 'com.google.gms:google-services:4.3.14'
    // ...
}
Run Code Online (Sandbox Code Playgroud)

该插件将允许处理google-services.json文件并生成可在应用程序代码中使用的 Android 资源。此外,它将允许安装 Firebase 相关库的依赖项,这将是下一步。

  1. 将此行添加到应用程序级别build.gradle文件中:
apply plugin: 'com.google.gms.google-services'
Run Code Online (Sandbox Code Playgroud)

资料来源:


Md.*_*hid 5

在 build.gradle(Module:app) 中添加此代码

\n\n
dependencies {\n    \xe2\x80\xa6\xe2\x80\xa6..\n    compile 'com.google.android.gms:play-services:10.0.1\xe2\x80\x99\n    \xe2\x80\xa6\xe2\x80\xa6  \n}\n
Run Code Online (Sandbox Code Playgroud)\n\n

如果之后仍然有问题,请在 build.gradle(Module:app) 中添加此代码

\n\n
defaultConfig {\n    \xe2\x80\xa6.\n    \xe2\x80\xa6...\n    multiDexEnabled true\n}\n\n\ndependencies {\n    \xe2\x80\xa6..\n    compile 'com.google.android.gms:play-services:10.0.1'\n    compile 'com.android.support:multidex:1.0.1'\n}\n
Run Code Online (Sandbox Code Playgroud)\n


归档时间:

查看次数:

109378 次

最近记录:

5 年,10 月 前