首页 > 解决方案 > 如何在 Build.gradle (app) 中添加这个插件

问题描述

应用插件:'com.google.gms.google-services' <-我应该在哪里添加这个?

所以我最近安装了一个新版本的 android studio 并且有一个新格式的 Gradel 插件那么我可以在哪里将应用插件放在下面的代码中?

plugins {
    id 'com.android.application'
 }

android {
    compileSdkVersion 30
    buildToolsVersion "30.0.3"

    defaultConfig {
        applicationId "com.social.login2"
        minSdkVersion 19
        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 'androidx.appcompat:appcompat:1.3.0'
    implementation 'com.google.android.material:material:1.4.0'
    implementation 'androidx.constraintlayout:constraintlayout:2.0.4'
    testImplementation 'junit:junit:4.+'
    androidTestImplementation 'androidx.test.ext:junit:1.1.3'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
}```

标签: androidfirebasegradle

解决方案


更改以下几行

plugins {
    id 'com.android.application'
 }

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

而不是应用插件,现在使用的方式是在插件块内给出 id 名称,然后在引号内给出 id。


推荐阅读