java - 更新到最新版本 4.3.7 后找不到 ID 为 'com.google.gms.google-services' 的插件

标签 java android kotlin

我已将我的 android studio 更新到最新版本 4.2。更新后,我更改了版本

classpath 'com.google.gms:google-services:4.3.5'
到最新版本
classpath 'com.google.gms:google-services:4.3.7'.
现在它显示了这个错误。
Caused by: org.gradle.api.plugins.UnknownPluginException: Plugin with id 'com.google.gms.google-services' not found.
build.gradle(项目级别):
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
    ext {
        kotlin_version = '1.5.0'
    }
    repositories {
        google()
        mavenCentral()
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:4.2.1'
        classpath 'com.google.gms:google-services:4.3.7'
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
    }
}

allprojects {
    repositories {
        google()
        jcenter()
    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}
build.gradle(应用程序级别)
plugins {
    id 'com.android.application'
    id 'kotlin-android'
}

android {
    compileSdkVersion 30
    buildToolsVersion "30.0.3"


    defaultConfig {
        applicationId "com.netcom.netsmartapp"
        minSdkVersion 23
        targetSdkVersion 30
        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 {
    implementation platform('com.google.firebase:firebase-bom:28.0.1')
    implementation 'com.google.firebase:firebase-auth'
    implementation 'androidx.appcompat:appcompat:1.2.0'
    implementation 'com.google.android.material:material:1.3.0'
    implementation 'androidx.constraintlayout:constraintlayout:2.0.4'
    implementation 'androidx.navigation:navigation-fragment-ktx:2.3.5'
    implementation 'androidx.navigation:navigation-ui-ktx:2.3.5'
    implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"

    testImplementation 'junit:junit:4.13.2'
    androidTestImplementation 'androidx.test.ext:junit:1.1.2'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'



}
apply plugin: 'com.google.gms.google-services' <--- This line shows error
错误指向 App Level Gradle File 中的这一行
apply plugin: 'com.google.gms.google-services' <--- This line shows error
我不知道为什么会这样。我还更新了我的 firebase 库。尽管它不起作用。请帮我解决一些问题。
使用 4.3.6 版本时崩溃:
com.android.build.gradle.internal.crash.ExternalApiUsageException: org.gradle.internal.metaobject.AbstractDynamicObject$CustomMessageMissingMethodException: Could not find method setVariantDir() for arguments [debug] on task ':app:processDebugGoogleServices' of type com.google.gms.googleservices.GoogleServicesTask
完整的崩溃日志:https://pastebin.com/Dpgm0jm7

最佳答案

更新至 4.3.8 以解决该问题。
旧答案
我在尝试升级时遇到了同样的问题。正在检查 the Maven Repo对于 Google Plugin,它仍然是 4.3.5。然而在 Google hosted Maven Repo是 4.3.7。 Google 托管 maven 上的说明说您需要添加

implementation("com.google.gms:google-services:4.3.7")
我没有时间测试,所以我恢复到 4.3.5,因为它工作得很好,直到谷歌修复问题或将 4.3.7 上传到 Maven。我建议你也这样做,除非某些东西不起作用。
更新 1
@Markers 报告更新到 4.3.7然后从 apply 中删除插件定义或 id在您的 build.gradle文件有效,但某些功能(如 Firebase 日志记录)无效。
我还没有测试过。如果有效,请在评论中告诉我们!
更新 2
版本 4.3.8 have been released在 Maven 存储库中。我会更新并查看它是否解决了问题(原则上应该)。如果是,那么这将是那些想要从 4.3.5 升级的人的解决方案

关于java - 更新到最新版本 4.3.7 后找不到 ID 为 'com.google.gms.google-services' 的插件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/67531489/

相关文章:

java - 计算小于 N 的以 2 为底的对数的最大整数

java - 客户端和服务器套接字之间交换的 "messages"结尾

java - 清理 Android 主要 Activity 代码

android - 限制可以在范围内运行的最大协程数

list - 如何在 Kotlin 中将 List<String> 转换为 Map<String, Int>?

java - 通过 Java 小程序加密表单上的文本字段;浏览器正在缓存加密文本;如何缓存明文?

Java 从 oracle 返回陈旧数据

android - 如何在 OpenGL ES 2 中正确缩放

android - 当与主题反跳时多次进行改造调用

java - 无法将实体类放入 getEntityClass 管理器方法中