当我添加谷歌服务插件时,Gradle会同步和/或组装库项目

时间:2017-08-21 10:22:36

标签: android android-studio firebase unity3d firebase-authentication

我想在我的Unity Android插件中添加Firebase Auth功能,所以 我跟着this guide并添加了

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

到app的build.gradle文件。但同步开始失败

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

这是一个完整的build.gradle

apply plugin: 'com.android.library'

android {
    compileSdkVersion 25
    buildToolsVersion '25.0.3'
    defaultConfig {
        minSdkVersion 19
        targetSdkVersion 25
        project.archivesBaseName = "AndroidPlugin"
        versionCode 1
        versionName "1.0"
    }

    lintOptions {
        abortOnError false
    }

    libraryVariants.all { variant ->
        variant.outputs.each { output ->
            def outputFile = output.outputFile
            if (outputFile != null && outputFile.name.endsWith('release.aar')) {
                def fileName = "${archivesBaseName}.aar"
                output.outputFile = new File(outputFile.parent, fileName)
            }
        }
    }
}


dependencies {
    provided fileTree(include: ['*.jar'], dir: 'libs')
    compile 'com.android.support:support-v4:25.3.1'
    compile 'com.android.support:appcompat-v7:25.3.1'
    compile 'com.android.support:design:25.3.1'
    compile "com.android.support:exifinterface:25.3.1"
    compile 'com.facebook.android:account-kit-sdk:4.+'
    compile 'com.google.firebase:firebase-auth:11.0.4'
}

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

Project build.gradle

buildscript {
    repositories {
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:2.3.3'
        classpath 'com.google.gms:google-services:3.1.0'

    }
}

allprojects {
    repositories {
        jcenter()
    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}

1 个答案:

答案 0 :(得分:0)

您尝试添加到项目build.gradle

buildscript {
    repositories {
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:2.2.0'
        classpath 'com.google.gms:google-services:3.0.0'
    }
}

allprojects {
    repositories {
        jcenter()
        maven { url "https://jitpack.io" }
    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}