简体   繁体   English

找不到 ID 为“com.google.gms.google-services”的插件。 [ Android ]

[英]Plugin with id 'com.google.gms.google-services' not found. [ Android ]

I was Setup firebase我是设置 firebase

Firebase Official link Firebase 官方链接
I'm Following This Link my 2nd step went through it correctly, but I think I am doing some mistakes in 3rd & the 4th There are some flaws in my code that I don't understand,我正在关注此链接,我的第二步正确完成了它,但我认为我在第三和第四步中犯了一些错误我的代码中存在一些我不理解的缺陷,
I will be glad if you can help us.如果你能帮助我们,我会很高兴。

build Gradle :- Project构建 Gradle :- Project

// Top-level build file where you can add configuration options common to all sub- 
projects/modules.
plugins {
id 'com.android.application' version '7.1.3' apply false
id 'com.android.library' version '7.1.3' apply false
}

task clean(type: Delete) {
delete rootProject.buildDir
}

build Gradle : Module构建 GradleModule

plugins {
 id 'com.android.application'
}

//code here..
apply plugin: 'com.google.gms.google-services'

android {
 compileSdk 32

 defaultConfig {
    applicationId "com.company.myfire"
    minSdk 21
    targetSdk 32
    versionCode 1
    versionName "1.0"

    testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
 }

 buildTypes {
    release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard- 
 rules.pro'
    }
 }
 compileOptions {
    sourceCompatibility JavaVersion.VERSION_1_8
    targetCompatibility JavaVersion.VERSION_1_8
 }
}

dependencies {
 classpath 'com.google.gms:google-services:4.3.10'
 implementation 'androidx.appcompat:appcompat:1.4.1'
 implementation 'com.google.android.material:material:1.6.0'
 implementation 'androidx.constraintlayout:constraintlayout:2.1.3'
 implementation platform('com.google.firebase:firebase-bom:30.0.0')
 implementation 'com.google.firebase:firebase-analytics'
 testImplementation 'junit:junit:4.13.2'
 androidTestImplementation 'androidx.test.ext:junit:1.1.3'
 androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
}

The plugin needs to be referenced in the root build.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
}

Then it can be applied in a module build.gradle :然后它可以应用于模块build.gradle

plugins {
    id 'com.android.application'
    id 'com.google.gms.google-services'
}

You can give it a try:你可以试一试:

Edit编辑

in build.gradle(Project: AppName)build.gradle(Project: AppName)

buildscript {
  dependencies {
     classpath 'com.google.gms:google-services:4.3.10'
  }
} // Top-level build file where you can add configuration options common 
  // to all sub-projects/modules.
plugins {
   id 'com.android.application' version '7.2.0' apply false
   id 'com.android.library' version '7.2.0' apply false
}

task clean(type: Delete) {
   delete rootProject.buildDir
}

in build.gradle(Module: AppName) :build.gradle(Module: AppName)中:

plugins {
 id 'com.android.application'
 id 'com.google.gms.google-services'
}

android {
 // rest code ....
}

dependencies {
 // here your dependencies
}

and make sure you have added google-services.json to your project.并确保您已将google-services.json添加到您的项目中。

and I will recommend you to connect firebase by android studio's firebase tool and avoid it manually.我会建议您使用 android 工作室的firebase 工具连接 firebase 并手动避免它。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 找不到 ID 为“com.google.gms.google-services”的插件 - Plugin with id 'com.google.gms.google-services' not found 通过添加此行来应对本机应用程序崩溃:apply plugin: 'com.google.gms.google-services' - react native app crash by adding this line: apply plugin: 'com.google.gms.google-services' 找不到 arguments [com.google.gms.google-services] 的方法 id() - Could not find method id() for arguments [com.google.gms.google-services] > 在 org.gradle.api.Project - > Could not find method apply() for arguments [com.google.gms.google-services] on project ':app' of type org.gradle.api.Project Flutter 找不到 com.google.android.gms.providerinstaller.dynamite 的本地模块描述符 class - Flutter Local module descriptor class for com.google.android.gms.providerinstaller.dynamite not found 找不到与 com.google.android.gms:play-services-base:[15.0.1,16.0.0) 匹配的任何版本 - Could not find any version that matches com.google.android.gms:play-services-base:[15.0.1,16.0.0) Flutter 和 google_sign_in 插件:PlatformException(sign_in_failed,com.google.android.gms.common.api.ApiException:10:,空) - Flutter and google_sign_in plugin: PlatformException(sign_in_failed, com.google.android.gms.common.api.ApiException: 10: , null) Lint 将 google 服务插件生成的 project_id 标记为 UnusedResource - Lint tags project_id generated by google services plugin as UnusedResource Flutter:使用 google_sign_in 时出现 PlatformException(sign_in_failed,com.google.android.gms.common.api.ApiException:10:,null) - Flutter : PlatformException(sign_in_failed, com.google.android.gms.common.api.ApiException: 10: , null) when using google_sign_in PlatformException(登录失败,com.google.android.gms.common.api.ApiException:12500:,null,空) - PlatformException(sign_in_failed, com.google.android.gms.common.api.ApiException: 12500: , null, null)
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM