Failed to apply plugin “com.google.gms.google-serv

2019-02-21 23:39发布

Here is my project build.gradle:

buildscript {
    ...
    dependencies {
        ...
        classpath 'com.google.gms:google-services:3.1.0'
    }
}

In one of the module's build.gradle I have this:

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

which results into the following error:

Could not get unknown property 'LibraryVariants' for object of type com.android.build.gradle.LibraryExtension.

Fun fact, if I set google-services version to 3.0.0, this specific error disappears, but Gradle asks me to downgrade versions of other google libraries, but I really do not want to do that.

How do I deal with these LibraryVariants?

2条回答
Luminary・发光体
2楼-- · 2019-02-22 00:10

You only set apply plugin: 'com.google.gms.google-services' in the app module, and in no other modules.

查看更多
啃猪蹄的小仙女
3楼-- · 2019-02-22 00:25

You must add one dependencies in your build.gradle(Project:project_name)

    classpath 'com.google.gms:google-services:3.1.0'

And add in your build.gradle(build.gradle:Module app)

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

dependencies {

compile 'com.android.support:appcompat-v7:25.3.1'
compile 'com.android.support:design:25.3.1'

 }
 apply plugin: 'com.google.gms.google-services'
查看更多
登录 后发表回答