【问题标题】:I keep receiving a gradle sync error when trying to add Firebase UI 2.3.0尝试添加 Firebase UI 2.3.0 时,我不断收到 gradle 同步错误
【发布时间】:2018-02-07 07:57:17
【问题描述】:

问题更新:在与教程的创建者交谈后,我尝试使用 Firebase 创建实时聊天。他告诉我改变你的 Gradle compile 'com.google.firebase:firebase-core:9.4.0' 编译'com.google.firebase:firebase-database:9.4.0'

如果是这种情况,我需要更改我的依赖项以使用此 9.4.0 版本吗?

       // Top-level build file where you can add configuration options common to all sub-projects/modules.

    buildscript {
        repositories {
            jcenter()
        }
        dependencies {
            classpath 'com.android.tools.build:gradle:2.3.3'
            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()
            maven { url 'https://maven.fabric.io/public' }  // <= ADD THIS
            maven {
                url "https://maven.google.com"
            }
        }
    }

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


Below is the Module:app Gradle
Here is where I am trying to compile the Firebase UI in order to make a chat application within my app:

apply plugin: 'com.android.application'

android {
    compileSdkVersion 26
    buildToolsVersion "26.0.1"
    defaultConfig {
        applicationId "com.example.aids.a09application"
        minSdkVersion 16
        targetSdkVersion 25
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
        aaptOptions.cruncherEnabled = false
        aaptOptions.useNewCruncher = false

    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}
android {
    useLibrary 'org.apache.http.legacy'
}
dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
        exclude group: 'com.android.support', module: 'support-annotations'
    })


    compile 'com.google.firebase:firebase-core:11.2.0'
    compile 'com.google.firebase:firebase-messaging:11.2.0'
    compile 'com.android.support:appcompat-v7:26.0.1'
    compile 'com.google.android.gms:play-services-maps:11.2.0'
    compile 'com.google.firebase:firebase-auth:11.2.0' // ADDED
    compile 'com.google.android.gms:play-services-auth:11.2.0' // ADDED
    compile 'com.android.support.constraint:constraint-layout:1.0.2'
    compile 'com.android.support:design:26.0.1'
    compile 'com.android.support:support-v4:26.0.1'
    compile 'com.android.support:recyclerview-v7:26.0.1'
    compile 'com.google.firebase:firebase-database:9.4.0'
    compile 'com.google.firebase:firebase-core:9.4.0'
}
apply plugin: 'com.google.gms.google-services'

这是我现在遇到的错误:

Error:Execution failed for task ':app:processDebugGoogleServices'.
> Please fix the version conflict either by updating the version of the google-services plugin (information about the latest version is available at https://bintray.com/android/android-tools/com.google.gms.google-services/) or updating the version of com.google.android.gms to 11.2.0.

【问题讨论】:

  • 为什么不添加最新的 Firebase 依赖项?例如。 'com.google.firebase:firebase-core:11.2.0'
  • 错误 - 无法解决 com.google.firebase:firebase-core:11.2.0 等
  • 如果您不想从 10.2.4 和 25.3.1 升级,请将firebase-ui-auth:2.3.0 降级为firebase-ui-auth:1.2.0
  • 更新了我的 Gradles,现在有一个新的错误。上面的问题更新了新的错误

标签: java android maven firebase gradle


【解决方案1】:

要将 Firebase 库的 11.2.0 版与 FirebaseUI 2.3.0 一起使用,您必须按如下方式更新您的依赖项:

compile 'com.google.firebase:firebase-core:11.2.0'
compile 'com.google.firebase:firebase-messaging:11.2.0'
compile 'com.android.support:appcompat-v7:26.0.1'
compile 'com.google.android.gms:play-services-maps:11.2.0'
compile 'com.google.firebase:firebase-auth:11.2.0' // ADDED
compile 'com.google.android.gms:play-services-auth:11.2.0' // ADDED
compile 'com.android.support.constraint:constraint-layout:1.0.2'
compile 'com.android.support:design:26.0.1'
compile 'com.android.support:support-v4:26.0.1'
compile 'com.android.support:recyclerview-v7:26.0.1'
compile 'com.firebaseui:firebase-ui-auth:2.3.0'

添加 firebase-authplay-services-auth 是必需的,因为使用 11.2.0 构建的 FirebaseUI 版本尚不可用。这在FirebaseUI documentation 中有解释。

您还应该进行以下更改:

compileSdkVersion 26
buildToolsVersion "26.0.1"

compileSdkVersion 26 的要求在Google Play Services Release Notes

当您将应用的 Play 服务依赖项升级到 11.2.0 或 稍后,您的应用程序的 build.gradle 也必须更新以指定 compileSdkVersion 至少为 26 (Android O)

【讨论】:

    【解决方案2】:

    由于您使用的是com.android.support:customtabs:26.0.1,因此您必须在repositories 中添加“https://maven.google.com”端点。
    自 25.4.0 以来的所有支持库都在 google maven repo 中,名称为 described here

    在你的情况下是这样的;

    allprojects {
        repositories {
            jcenter()
            maven { url 'https://maven.fabric.io/public' }  // <= ADD THIS
            maven {
                url "https://maven.google.com"
            }
        }
    }
    

    此外,如果您想添加最新的 Firebase 库 v. 11.2.0,您必须添加与 described here 相同的存储库。

    【讨论】:

      【解决方案3】:

      如果尚未安装,您必须转到 SDK 管理器并下载 API 26 (Android 8.0) 的 SDK 平台文件。然后将所有支持库文件更新到 26.0.1 版本,如编译 'com.android.support:design:25.3.1' 以编译 'com.android.support:design:26.0.1' 等等。您还需要将 compileSdkVersion 25 更改为 26,将 buildToolsVersion "25.0.2" 更改为 "26.0.1" 并将 targetSdkVersion 25 更改为 26。并将 maven "https://maven.google.com" 添加到 repositories

      Firebase 正在寻找版本 26.0.1 的支持库。而且由于它要么没有安装,要么你的 buildToolsVersion 和 compileSdkVersion 没有指向它,所以 gradle 无法解决它们。

      【讨论】:

        猜你喜欢
        • 2018-05-05
        • 2019-07-01
        • 1970-01-01
        • 2020-03-19
        • 2016-05-05
        • 1970-01-01
        • 2017-06-15
        • 2018-02-26
        • 1970-01-01
        相关资源
        最近更新 更多