【问题标题】:Error apply plugin: 'com.google.gsm.google-services' also added classpath 'com.google.gms:google-services:4.2.0'错误应用插件:“com.google.gsm.google-services”还添加了类路径“com.google.gms:google-services:4.2.0”
【发布时间】:2019-08-26 06:33:00
【问题描述】:

我正在使用 firebase 实时数据库。当我想同步 gradle 时,我收到此错误消息: 未找到 ID 为“com.google.gsm.google-services”的插件。

我已经下载了 google-services.json 并将其添加到我在项目视图中的应用程序文件夹中 我已经尝试了许多类路径,包括:

classpath 'com.google.gms:google-services:4.2.0'
classpath 'com.google.gms:google-services:4.3.1'
classpath 'com.google.gms:google-services:3.0.0'

项目等级:

{buildscript 
    repositories {
        google()
        jcenter()    
}
    dependencies {
        classpath 'com.android.tools.build:gradle:3.4.2'
        classpath 'com.google.gms:google-services:4.2.0'
        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

allprojects {
    repositories {
        google()
        jcenter()

    }
}

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

我的模块应用是:

apply plugin: 'com.android.application'

android {
    compileSdkVersion 28
    defaultConfig {
        applicationId "com.example.esppad.friendlychat2"
        minSdkVersion 21
        targetSdkVersion 28
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        }
    }
}


dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])

    implementation 'com.android.support:appcompat-v7:28.0.0'
    implementation 'com.android.support.constraint:constraint-layout:1.1.3'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'com.android.support.test:runner:1.0.2'
    androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
    implementation 'com.github.bumptech.glide:glide:3.6.1'
    implementation 'com.google.firebase:firebase-database:19.0.0'

}
apply plugin: 'com.google.gsm.google-services'

【问题讨论】:

  • 应用插件替换时出现拼写错误,请使用此行 apply plugin: 'com.google.gms.google-services'

标签: android android-studio gradle


【解决方案1】:

应用插件:“com.google.gsm.google-services”不得放在依赖项中

在下面的依赖项之后添加它,

dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])

implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
implementation 'com.github.bumptech.glide:glide:3.6.1'
implementation 'com.google.firebase:firebase-database:19.0.0'
}

apply plugin: 'com.google.gsm.google-services'

【讨论】:

  • 对不起,就像你说的,但我粘贴不正确。已经编辑过
【解决方案2】:

你在这行有错字:apply plugin: 'com.google.gsm.google-services'应该是gms而不是gsm,像这样:

apply plugin: 'com.android.application'

android {
    compileSdkVersion 28
    defaultConfig {
        applicationId "com.example.esppad.friendlychat2"
        minSdkVersion 21
        targetSdkVersion 28
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        }
    }
}


dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])

    implementation 'com.android.support:appcompat-v7:28.0.0'
    implementation 'com.android.support.constraint:constraint-layout:1.1.3'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'com.android.support.test:runner:1.0.2'
    androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
    implementation 'com.github.bumptech.glide:glide:3.6.1'
    implementation 'com.google.firebase:firebase-database:19.0.0'
}

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

【讨论】:

  • 对不起,就像你说的,但我粘贴不正确。已经编辑过
猜你喜欢
  • 2019-06-23
  • 2019-11-30
  • 2017-11-14
  • 1970-01-01
  • 1970-01-01
  • 2021-12-04
  • 2019-01-19
  • 2019-08-13
  • 2015-08-12
相关资源
最近更新 更多