Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

unknown property 'LibraryVariants' in build.gradle

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

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

Error:(56, 0) Could not get unknown property 'LibraryVariants' for object of type com.android.build.gradle.LibraryExtension.

It happened after I installed Firebase.

How to solve this?

like image 996
Nizar Avatar asked Jul 03 '17 11:07

Nizar


3 Answers

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'
like image 143
hansonchris Avatar answered Nov 09 '22 16:11

hansonchris


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
}
like image 42
mengoni Avatar answered Nov 09 '22 17:11

mengoni


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'
like image 22
HB. Avatar answered Nov 09 '22 18:11

HB.