簡體   English   中英

找不到插件:“com.google.gms.google-services”

[英]Could not found plugin: 'com.google.gms.google-services'

我是 Android 的新手。 我正在研究 firebase 應用程序項目我已經添加了谷歌服務插件。 但它向我顯示錯誤:找不到應用插件谷歌服務。

應用程序:gradle

apply plugin: 'com.android.application'

android {
  compileSdkVersion 32
  defaultConfig {
    applicationId "com.example.project.app"
    minSdkVersion 17
    targetSdkVersion 32
    versionCode 1
    versionName "1.0"
    testInstrumentationRunner
   "android.support.test.runner.AndroidJUnitRunner"
  }

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

dependencies
{
  implementation fileTree(dir: 'libs', include: ['*.jar'])
  implementation 'com.android.support:appcompat-v7:26.+'
  implementation 'com.android.support.constraint:constraint-layout:1.0.2'
  implementation 'com.google.firebase:firebase-core:16.0.1'
  implementation 'com.github.rey5137:material:1.2.5'
  implementation 'com.android.support:cardview-v7:26.1.0'
  implementation 'com.google.firebase:firebase-database:16.0.1'
  implementation 'io.paperdb:paperdb:2.6'
  testImplementation 'junit:junit:4.12'
  androidTestImplementation 'com.android.support.test:runner:1.0.1'
  androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'
  implementation 'com.android.support:recyclerview-v7:26.+'
}
apply plugin: 'com.gooogle.gms.google-services'

你是 Android 的新手。
所以首先嘗試 Invalidate Cachce Restart 或清理項目。

在您的項目中,您有兩個build.gradle文件,一個在root文件夾中,另一個在app文件夾中。 您需要將這行代碼添加到根文件夾中的build.gradle文件中

如果您使用 Gradle Kotlin DSL

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

或者

buildscript {
    repositories {
        mavenCentral()
        google()
    }

    dependencies {
        classpath 'com.android.tools.build:gradle:7.0.4'
        classpath 'com.google.gms:google-services:4.3.13'
    }
}

allprojects {
    repositories {
        mavenCentral()
        google()
    }
}

只有在那之后,您才能在您的app文件夾中的build.gradle中添加和編譯它:

如果您使用 Gradle Kotlin DSL

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

或者

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

暫無
暫無

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

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