android - 错误构建gradle

标签 android gradle android-gradle-plugin

添加apply插件后:'com.google.gms.google-services'。我收到以下错误

An error occurs after sync.ERROR: No such property: applicationVariants for class: java.lang.String



打开文件。
apply plugin: 'com.android.application'
android {
compileSdkVersion 29
buildToolsVersion "29.0.2"
defaultConfig {
    minSdkVersion 16
    targetSdkVersion 29
    versionCode 1
    versionName "1.0"
    testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
repositories {
    maven { url 'https://jitpack.io' }
}
buildTypes {
    release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
    }
}
}

dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'androidx.appcompat:appcompat:1.1.0'
implementation 'com.google.firebase:firebase-analytics:17.2.1'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
implementation 'com.google.android.material:material:1.0.0'
implementation 'androidx.cardview:cardview:1.0.0'
implementation 'com.github.bumptech.glide:glide:4.7.1'
implementation 'com.github.PhilJay:MPAndroidChart:v2.2.4'

testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test:runner:1.2.0'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
implementation("com.mikepenz:materialdrawer:6.0.8@aar") {
    transitive = true
}
}

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

最佳答案

尝试添加classpath 'com.google.gms:google-services:4.3.3'并删除带有“apply plugin”的行。
它应该工作。

关于android - 错误构建gradle,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58656753/

相关文章:

java - 无版本 gradle 依赖项

gradle.properties 无法使用点符号读取属性

android - 错误 :Execution failed for task ':app:dexDebug' . Parse.com

android - 我的 Android 应用程序出现重复输入错误

android - 使用具有更高 minSdkVersion 的库

android - Android中有没有类可以用来衡量网页加载时间的?

Android 如何将与 ListView 项目相关的数据从 sqlite 数据库传递到下一个 Activity

android - 频繁更新小部件(比 updatePeriodMillis 允许的更频繁)

android - Gradle 构建错误 : Cannot get property 'dirName' on null object

java - 我可以使用 jfk 的 Map 1 键到多值吗?