【问题标题】:Could not found plugin: 'com.google.gms.google-services'找不到插件:\'com.google.gms.google-services\'
【发布时间】:2022-09-20 21:44:03
【问题描述】:

我是 Android 新手。我正在开发 Firebase 应用程序项目。我已经添加了谷歌服务插件。但它向我显示了这个错误:找不到插件:\'com.google.gms.google-services\'。

应用程序: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\'

    标签: java android gradle


    【解决方案1】:

    你是安卓新手。
    所以首先尝试 Invalidate Cache Restart 或清理项目。

    【讨论】:

      【解决方案2】:

      在您的项目中,您有两个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()
          }
      }
      

      只有在那之后,您才能在 build.gradleapp 文件夹中添加和编译它:

      如果你使用 Gradle Kotlin DSL

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

      或者

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

      【讨论】:

      • 您的回答是正确的,但我的问题已通过 Invalidate Cache Restart 解决!
      猜你喜欢
      • 2021-12-22
      • 2017-02-14
      • 1970-01-01
      • 2020-02-24
      • 2021-02-27
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多