簡體   English   中英

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

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

我是設置 firebase

Firebase 官方鏈接
我正在關注此鏈接,我的第二步正確完成了它,但我認為我在第三和第四步中犯了一些錯誤我的代碼中存在一些我不理解的缺陷,
如果你能幫助我們,我會很高興。

構建 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
}

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

該插件需要在根目錄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
}

然后它可以應用於模塊build.gradle

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

你可以試一試:

編輯

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
}

build.gradle(Module: AppName)中:

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

android {
 // rest code ....
}

dependencies {
 // here your dependencies
}

並確保您已將google-services.json添加到您的項目中。

我會建議您使用 android 工作室的firebase 工具連接 firebase 並手動避免它。

> 在 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

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM