我在此行的build.gradle中有以下错误:
apply plugin: 'com.google.gms.google-services'
错误:(56,0)无法为com.android.build.gradle.LibraryExtension类型的对象获取未知属性“LibraryVariants”。
它发生在我安装Firebase之后。
怎么解决这个?
将以下内容添加到@project级别gradle文件中:
classpath 'com.android.tools.build:gradle:1.3.0'
classpath 'com.google.gms:google-services:3.0.0'
将以下内容添加到@app level gradle文件中:
// Dependency for Google Sign-In
compile 'com.google.android.gms:play-services-auth:9.4.0'
申请插件
apply plugin: 'com.google.gms.google-services'
错误消息,错误:无法获取com.android.build.gradle.LibraryExtension类型的对象的未知属性“LibraryVariants”,表示此插件需要应用于使用com.android.application
插件的模块。
因此,简单的解决方案是仅在您的应用程序模块中包含google-services插件,而不是您的库模块:
apply plugin: 'com.android.application'
apply plugin: 'com.google.gms.google-services'
我遇到了同样的问题并解决了更新gradle和google-services版本的问题。
// 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
}