【问题标题】:how to add This plug in in Build.gradle (app)如何在 Build.gradle (app) 中添加这个插件
【发布时间】:2021-09-20 21:59:32
【问题描述】:

应用插件:'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'
}```

【问题讨论】:

    标签: android firebase gradle


    【解决方案1】:

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

    或者就像 plugins 块中的最后一个插件一样

    【讨论】:

      【解决方案2】:

      更改以下行

      plugins {
          id 'com.android.application'
       }
      

      到

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

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

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 2016-01-19
        • 2018-12-07
        • 2017-10-06
        • 1970-01-01
        • 2016-03-28
        • 1970-01-01
        • 2019-12-28
        相关资源
        最近更新 更多