java - 未找到 ID 为 'com.google.gms.google-services' 的插件。 [ 安卓 ]

标签 java android firebase

我正在设置 firebase

Firebase Official link
我正在关注此链接,我的第 2 步正确完成了它,但我认为我在第 3 步和第 4 步中犯了一些错误 我的代码中有一些我不理解的缺陷,
如果你能帮助我们,我会很高兴。

构建 Gradle:- 项目

// 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
}

构建 Gradle:模块

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'
}

最佳答案

插件需要添加到类路径中:

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

然后可以在模块中应用:

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

关于java - 未找到 ID 为 'com.google.gms.google-services' 的插件。 [ 安卓 ],我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/72208587/

相关文章:

javascript - 为基于 Web 的应用程序禁用多用户登录

java - 谁在阅读 logback.xml

java - 替换 android 启动器 Activity 动画

android - 如何在android中获取两位数的日期和时间?

javascript - Firebase 规则 - 只读查询中的值

firebase - 如何使用 Riverpod 包从 Flutter 中的 firebase 集合中获取所有文档?

java - Java进程什么时候在shutdown hook后终止?

android - Google Play 游戏服务成就加载

如果文档 ID 包含字符串,则 Firebase Firestore 安全规则允许

java - 如何在 Apache Beam 中设置 PCollection<List<String>> 的编码器?