unknown property 'LibraryVariants' in build.gradle

前端 未结 3 2088
死守一世寂寞
死守一世寂寞 2020-12-20 15:43

I have the error below in build.gradle at this line:

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

Error:(56, 0) Could n

相关标签:
3条回答
  • 2020-12-20 16:13

    Add the following to the @project level gradle file:

    classpath 'com.android.tools.build:gradle:1.3.0'
    classpath 'com.google.gms:google-services:3.0.0'
    

    Add the following to the @app level gradle file:

    // Dependency for Google Sign-In
    compile 'com.google.android.gms:play-services-auth:9.4.0'
    

    Apply plugin

    apply plugin: 'com.google.gms.google-services'
    
    0 讨论(0)
  • 2020-12-20 16:18

    The error message, Error: Could not get unknown property 'LibraryVariants' for object of type com.android.build.gradle.LibraryExtension, indicates that this plugin needs to be applied to a module which uses the com.android.application plugin.

    So, the simple solution is to only include the google-services plugin in your application module and not your library module:

    apply plugin: 'com.android.application'
    apply plugin: 'com.google.gms.google-services'
    
    0 讨论(0)
  • 2020-12-20 16:28

    I had the same problem and solved it updating gradle and google-services versions.

    // Top-level build file where you can add configuration options common to all sub-projects/modules.
    buildscript {
        repositories {
            google()
            jcenter()
        }
        dependencies {
            classpath 'com.android.tools.build:gradle:3.0.0'
            classpath 'com.google.gms:google-services:3.1.1'
            // NOTE: Do not place your application dependencies here; they belong
            // in the individual module build.gradle files
        }
    }
    
    allprojects {
        repositories {
            google()
            jcenter()
        }
    }
    
    task clean(type: Delete) {
        delete rootProject.buildDir
    }
    
    0 讨论(0)
提交回复
热议问题