android - 添加 firebase 依赖项会导致 gradle 同步失败

标签 android firebase gradle kotlin android-gradle-plugin

我通过 Tools->Firebase->Add Real Time Database 添加了 firebase 数据库依赖项到您的应用程序方法,这导致我的 gradle 同步失败。我猜测依赖项存在冲突(因为我已经使用 firebase 为我的应用程序设置了 google 登录并且一切正常)或者加载了错误的依赖项

implementation 'com.google.firebase:firebase-database:16.0.1:15.0.0'

模块 Gradle 文件:
apply plugin: 'com.android.application'

apply plugin: 'kotlin-android'

apply plugin: 'kotlin-android-extensions'
apply plugin: 'com.google.gms.google-services'

android {
    compileSdkVersion 28
    defaultConfig {
        applicationId "nus.is3261.kotlinapp"
        minSdkVersion 21
        targetSdkVersion 28
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
    implementation 'com.android.support:appcompat-v7:28.0.0'
    implementation 'com.android.support.constraint:constraint-layout:1.1.3'
    implementation 'com.android.support:support-v4:28.0.0'
    implementation 'com.android.support:design:28.0.0'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'com.android.support.test:runner:1.0.2'
    androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
    implementation 'com.google.firebase:firebase-auth:16.0.5'
    implementation 'com.google.firebase:firebase-core:16.0.4'
    implementation 'com.google.android.gms:play-services-auth:16.0.1'
    implementation 'com.shaishavgandhi:login-buttons:1.0.0'
    compile 'com.github.bumptech.glide:glide:4.8.0'
    annotationProcessor 'com.github.bumptech.glide:compiler:4.8.0'
    implementation 'com.google.firebase:firebase-database:16.0.1:15.0.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 {
    ext.kotlin_version = '1.2.70'
    repositories {
        google()
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.2.1'
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
        classpath 'com.google.gms:google-services:4.1.0'

        // 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
}

最佳答案

尝试更换

implementation 'com.google.firebase:firebase-database:16.0.1:15.0.0'


implementation 'com.google.firebase:firebase-database:16.0.4'

关于android - 添加 firebase 依赖项会导致 gradle 同步失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53128350/

相关文章:

android - transformClassesAndResourcesWithProguardForRelease 失败

android - 找不到leakcanary-analyzer.aar,也找不到可用的网址

android - Android Studio:Gradle项目同步失败。基本功能将无法正常工作

android - RecyclerView OnScrollStateChanged() 和 onScrolled()

android - MPAndroidChart:x 轴上的日期 - 粘性月份和年份

Android 理解屏幕尺寸

javascript - 如何在firebase云函数中添加时间戳

java - Java 2 中的 DOM 解析问题

android - 如何用文本框中的值替换文档路径?

android - Firebase 远程配置总是命中服务器