问题更新:与教程的创建者交谈后,我尝试使用 Firebase 创建实时聊天。他告诉我在你的 Gradle 中更改编译 '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 库版本 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-auth
和 play-services-auth
,因为使用 11.2.0 构建的 FirebaseUI 版本尚不可用。 FirebaseUI documentation 对此进行了解释。 .
您还应该进行以下更改:
compileSdkVersion 26
buildToolsVersion "26.0.1"
compileSdkVersion 26
的要求位于 Google Play Services Release Notes 中:
When you upgrade your app’s Play services dependencies to 11.2.0 or later, your app’s build.gradle must also be updated to specify a compileSdkVersion of at least 26 (Android O)
关于java - 尝试添加 Firebase UI 2.3.0 时,我不断收到 gradle 同步错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45946241/