【问题标题】:Plugin with id 'com.google.gms.google-services' not found未找到 ID 为“com.google.gms.google-services”的插件
【发布时间】:2017-02-14 23:59:40
【问题描述】:

我已关注此link 在我的应用中集成广告。但它显示了这个错误:

这是我的 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'

}

}

广告未在真实设备中显示。请帮助我 这是我更新类路径后的错误 error

【问题讨论】:

  • 只需要从控制台开发者google生成google services json文件,放到app目录下即可。
  • 检查这个并按照这里给出的步骤stackoverflow.com/questions/34401143/…
  • 在哪里可以找到 google 服务?
  • 单击答案中给出的链接选择您的项目并获取配置文件,它会要求您下载文件。
  • 任何答案都不起作用。但是重置Android Studios解决了检查这个重置:-stackoverflow.com/questions/19384033/…

标签: android firebase admob


【解决方案1】:

遇到同样的问题。

通过添加依赖修复

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

build.gradle

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

【讨论】:

  • 文档还强调了在文件底部添加apply plugin: 'com.google.gms.google-services' 并以斜体书写的重要性。 “在你的模块(应用级)Gradle 文件(通常是 app/build.gradle)中,在文件底部添加一行。”
  • 先生,在 build.gradle 中添加上述内容后出现错误:> 找不到参数 [com.google.gms:google-services:3.0.0] 的方法 lasspath()
  • 我也收到了lasspath 错误,我在互联网上只能找到 Kapil Soni 的消息,这些消息都没有答案。所以现在有我们两个了,先生,你并不孤单!
  • 我想它对除了 Kapil 和我之外的任何人都没有用,但是要解决 lasspath 问题,只需运行 grep -R 'lasspath' * | grep -i --invert-match 'classpath' 并且您应该找到导致问题的文件和行(基本上,一个错字)。
  • 版本:classpath 'com.google.gms:google-services:4.3.5 最新版本号:'developers.google.com/android/guides/google-services-plugin
【解决方案2】:

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

参考项目级 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
    }
}

【讨论】:

    【解决方案3】:

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


    app.gradle 中的应用插件:'com.google.gms.google-services' 如下所示:

    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'
    

    将类路径添加到项目的 gradle

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

    SDK 管理器上的 Google Play 服务库:

    【讨论】:

    【解决方案4】:

    遇到同样的问题。

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

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

    添加这个解决了我

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

    到根 build.gradle。

    【讨论】:

    • 糟糕,我使用了应用程序build.gradle
    【解决方案5】:

    只需将“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
    
        }
    }
    

    并将“应用插件:'com.google.gms.google-services'”添加到 android/app/build.gradle 中的文件末尾,看起来像这样

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

    【讨论】:

      【解决方案6】:

      转到Setting > Android SDK > SDK Tools > Google Play Services

      【讨论】:

        【解决方案7】:

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

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

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

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

        编辑:

        这个问题现在已经解决了:

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

        【讨论】:

          【解决方案8】:

          在 build.gradle(Module:app) 添加这段代码

          dependencies {
              ……..
              compile 'com.google.android.gms:play-services:10.0.1’
              ……  
          }
          

          如果之后还有问题,那么在 build.gradle(Module:app) 中添加这段代码

          defaultConfig {
              ….
              …...
              multiDexEnabled true
          }
          
          
          dependencies {
              …..
              compile 'com.google.android.gms:play-services:10.0.1'
              compile 'com.android.support:multidex:1.0.1'
          }
          

          【讨论】:

          • 结果 - 添加 multiDexEnabled true & compile 'com.android.support:multidex:1.0.1' 不能解决问题。你能解释一下这应该如何解决这个问题吗?
          【解决方案9】:

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

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

          而不是:

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

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

          嘿...很容易错过。

          【讨论】:

            【解决方案10】:

            在尝试将 Firebase 与 Flutter 应用程序集成时结束了这个线程。所以,如果你在 Flutter 中遇到同样的问题,下面的步骤为我解决了这个问题。

            免责声明:第一步与文档中描述的相同 以及在线找到的每个答案/教程。我只是在一个 为了保持我的回答一致而保持高水平。

            实际的步骤是不同的并解决了问题是最后一个 一个

            1. 在您的 flutter_app/android/app 目录中添加 google-services.json。
            2. 在 android/build.gradle 添加:
            repositories {
                google()
                jcenter()
                maven {
                    url "https://maven.google.com"
                }
            }
            
            dependencies {
                    classpath 'com.android.tools.build:gradle:3.5.0'
                    classpath 'com.google.gms:google-services:4.3.4'
                    classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
                }
            
            allprojects {
                repositories {
                    google()
                    jcenter()
                    maven {
                        url "https://maven.google.com"
                    }
                }
            }
            
            1. 在 android/app/build.gradle 上添加:
            apply plugin: 'com.android.application'
            apply plugin: 'kotlin-android'
            apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"
            apply plugin: 'com.google.gms.google-services'
            
            1. 在 android/app/build.gradle 上还添加以下内容:
            dependencies {
                implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
            
                implementation platform('com.google.firebase:firebase-bom:26.3.0')
                implementation 'com.google.firebase:firebase-analytics'
                implementation 'com.google.firebase:firebase-messaging'
            
                testImplementation 'junit:junit:4.+'
                androidTestImplementation 'androidx.test.ext:junit:1.1.2'
                androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
            }
            

            您可以在 https://gitlab.com/ecocupaegean/ecocupaegean/-/tree/master/ 找到一个工作演示,要运行该应用程序,您只需添加自己的 google-services.json,并为 google maps geolocation API 指定一个 API KEY。

            【讨论】:

              【解决方案11】:

              我将 google-services 类路径版本从 4.2.0 更改为 3.0.0

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

              然后重建项目,然后奇怪的是它建议我将firebase核心添加到项目中。

              然后我在应用程序(模块)上添加了 firebase 核心

              implementation 'com.google.firebase:firebase-messaging:16.0.8'
              

              然后错误神奇地消失了。

              【讨论】:

                【解决方案12】:

                在appbuild.gradle依赖中,必须添加如下代码

                classpath 'com.google.gms:google-services:$last_version'
                

                然后请检查 Google Play Service SDK 工具安装状态。

                【讨论】:

                  【解决方案13】:

                  build.gradle 中设置 Gradle plugins 同时工作方式如下:

                  plugins {
                      id "com.android.application" version "7.1.2" apply false
                      id "com.android.library" version "7.1.2" apply false
                      id "com.google.gms.google-services" version "4.3.10" apply false
                  }
                  

                  【讨论】:

                    【解决方案14】:
                    apply plugin: 'com.google.gms.google-services'
                    

                    在您的应用程序 gradle.build 的底部添加上述行。

                    【讨论】:

                    • @subrahmanyam-boyapati 为什么在底部?这是怎么回事?我认为解释为什么更重要
                    • 我怀疑立场决定了问题。
                    【解决方案15】:

                    在项目的 build.gradle 中添加以下内容

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

                    【讨论】:

                      猜你喜欢
                      • 2021-12-22
                      • 1970-01-01
                      • 2020-02-24
                      • 2021-02-27
                      • 2020-12-08
                      • 2018-04-19
                      • 2022-09-20
                      • 1970-01-01
                      相关资源
                      最近更新 更多