繁体   English   中英

如何在Build.gradle(app)中添加这个插件

[英]how to add This plug in in Build.gradle (app)

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

所以我最近安装了一个新版本的android studio,并且Gradel插件有一种新格式,那么我可以将apply插件放在下面的代码中的什么位置?

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'
}```

您可以将它添加到build.gradle文件的末尾,因为这是推荐的方式。

或者只是作为最后一个插件plugins堵顶

更改以下几行

plugins {
    id 'com.android.application'
 }

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

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

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM