Android错误 - Gradle项目同步失败



我正在尝试从firebase读取数据,但我无法同步我的gradle项目。

我去了Tools -> Firebase,并添加了身份验证和实时数据库作为我在YouTube上引用的视频。

但是我的Gradle Project Sync保持失败之后。

我已经在Google上搜索了此问题,并试图更新我的版本,但它不起作用。

我还在build.gradle文件的底部添加了com.google.gms.googleservices.GoogleServicesPlugin.config.disableVersionCheck = true,但它说它是不必要的合格参考。

这是一些代码。

  1. build.gradle
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
    repositories {
        google()
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.2.1'
        classpath 'com.google.gms:google-services:4.0.1'
        // 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
}
  1. build.gradle(模块:app(
apply plugin: 'com.android.application'
apply plugin: 'com.google.gms.google-services'
android {
    compileSdkVersion 28
    defaultConfig {
        applicationId "com.el.ariby"
        minSdkVersion 21
        targetSdkVersion 28
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        }
    }
    dataBinding {
        enabled = true
    }
}
dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation 'com.google.firebase:firebase-core:16.0.8'
    //noinspection GradleCompatible
    implementation 'com.android.support:appcompat-v7:28.0.0'
    implementation 'com.google.firebase:firebase-database:15.0.1'
    implementation 'com.google.firebase:firebase-auth:16.0.3'
    implementation 'com.google.firebase:firebase-storage:16.0.1'
    //implementation 'com.google.firebase:firebase-auth:16.2.1'
    //implementation 'com.google.firebase:firebase-storage:16.1.0'
    //implementation 'com.google.firebase:firebase-database:16.0.1:15.0.0'
    implementation 'com.android.support.constraint:constraint-layout:1.1.3'
    implementation 'com.android.support:design:28.0.0'
    implementation 'com.github.bumptech.glide:glide:4.9.0'
    implementation 'com.squareup.retrofit2:retrofit:2.5.0'
    implementation 'com.google.code.gson:gson:2.8.5'
    implementation 'com.squareup.retrofit2:converter-gson:2.5.0'
    implementation 'com.squareup.okhttp3:okhttp:3.4.2'
    implementation 'com.squareup.okhttp3:logging-interceptor:3.9.1'
    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.1:15.0.0'
    implementation 'com.google.firebase:firebase-database:16.0.1:15.0.0'
}
com.google.gms.googleservices.GoogleServicesPlugin.config.disableVersionCheck = true

更新抱歉,我忘了添加错误消息。

Failed to resolve: firebase-database-15.0.0
Open File

Failed to resolve: firebase-auth-15.0.0
Open File

我真的希望我可以同步文件..

谢谢!

请下次提供每个控制台或XLINT的更多详细信息,以便我们评估问题。但是我已经遇到了阻止同步的错误,您使用了引起冲突的不同版本的库。请注意,如果您使用一个版本的Firebase库,则必须使用同一版本的所有库。错误在这里:

implementation 'com.google.firebase:firebase-database:15.0.1' // 15.0.1????
implementation 'com.google.firebase:firebase-auth:16.0.3'  // 16.0.3???
implementation 'com.google.firebase:firebase-storage:16.0.1'  //16.0.1???

示例:

 implementation fileTree(dir: 'libs', include: ['*.jar'])

//noinspection GradleCompatible
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.google.firebase:firebase-core:16.0.3' //this is the same version
implementation 'com.google.firebase:firebase-auth:16.0.3' //than this
implementation 'com.google.firebase:firebase-database:16.0.3'
implementation 'com.google.firebase:firebase-storage:16.0.3'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
implementation 'com.android.support:design:28.0.0'
implementation 'com.github.bumptech.glide:glide:4.9.0'
implementation 'com.squareup.retrofit2:retrofit:2.5.0'
implementation 'com.google.code.gson:gson:2.8.5'
implementation 'com.squareup.retrofit2:converter-gson:2.5.0'
implementation 'com.squareup.okhttp3:okhttp:3.4.2'
implementation 'com.squareup.okhttp3:logging-interceptor:3.9.1'
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.1:15.0.0'
implementation 'com.google.firebase:firebase-database:16.0.1:15.0.0'

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

最新更新