android - Gradle DSL 方法未找到 : 'classpath()' after adding firebaseui libraries

标签 android firebase gradle firebaseui

我添加了 firebase UI 库,添加 Google maven 后出现错误。
可能的原因是我使用的Android Gradle插件版本不包含该方法,但是我升级了插件仍然报错。

这是模块 Gradle 文件:

apply plugin: 'com.android.application'


repositories {
    mavenLocal()
    flatDir {
        dirs 'libs'
    }
}

android {
    compileSdkVersion 24
    buildToolsVersion "24.0.1"

    defaultConfig {
        applicationId "com.google.firebase.udacity.friendlychat"
        minSdkVersion 16
        targetSdkVersion 24
        versionCode 1
        versionName "1.0"
        multiDexEnabled = true

    }
    dexOptions {
        javaMaxHeapSize = "4g"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
    packagingOptions {
        exclude 'META-INF/LICENSE'
        exclude 'META-INF/LICENSE-FIREBASE.txt'
        exclude 'META-INF/NOTICE'
    }
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    testCompile 'junit:junit:4.12'

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

    // Displaying images
    compile 'com.github.bumptech.glide:glide:3.6.1'
    compile 'com.google.firebase:firebase-core:11.0.2'
    compile 'com.google.firebase:firebase-storage:11.0.2'
    compile 'com.google.firebase:firebase-auth:11.0.2'
    compile 'com.google.android.gms:play-services:11.0.2'
    compile 'com.firebaseui:firebase-ui:2.1.0'



}

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

和项目 Gradle 文件:
// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
    repositories {
        jcenter()
        mavenLocal()
    }
    }
    dependencies {
        apply plugin: 'idea'
        classpath 'com.android.tools.build:gradle:2.2.2'
        classpath 'com.google.gms:google-services:3.1.0'

        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }


allprojects {
    repositories {
        maven {
            url "https://maven.google.com"
        }
        jcenter()
    }
}

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

最佳答案

更改项目 Gradle 文件后,我得到了解决方案:

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

        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }

}
    allprojects {
        repositories {
            jcenter()
        } }

关于android - Gradle DSL 方法未找到 : 'classpath()' after adding firebaseui libraries,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45287235/

相关文章:

java - 如何将保护级别从正常更改为危险

android - Firebase Crashlytics 自定义日志未出现在控制台中

ios - 适用于 iOS 的 Firebase - 控制台卡在未针对云消息传递进行配置

android - 从 Eclipse + SVN 迁移到 Android Studio

java - Android Studio 3.2- “Waiting for build to finish”&无法下载gradle.jar

android - 如何避免Retrofit在HTTP URL中编码单引号?

java - 虚拟设备中没有后退按钮

android - 使用 JakeWharton/ViewPagerIndicator 时部分显示下一项和上一项

android - 是否可以从父类(super class)中获取 Kotlin 子类类型?

java - 升级Gradle后Lombok停止工作