Ошибка Android - сбой синхронизации проекта Gradle - PullRequest
1 голос
/ 03 мая 2019

Я пытаюсь прочитать данные из firebase, но почему-то не могу синхронизировать свой проект Gradle.

Я перешел на Tools -> Firebase и добавил базу данных аутентификации и реального времени в качестве видео, которое я сослался на Youtube.

Но после этого моя синхронизация в проекте Gradle не удалась.

Я искал эту проблему в Google и пытался обновить свои версии, но она не работала.

Я также добавил com.google.gms.googleservices.GoogleServicesPlugin.config.disableVersionCheck = true внизу файла build.gradle, но он говорит, что это ненужная квалифицированная ссылка.

Вот некоторый код.

  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 (Модуль: приложение)
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

UPDATE Извините, я забыл добавить сообщения об ошибках.

Failed to resolve: firebase-database-15.0.0
Open File


Failed to resolve: firebase-auth-15.0.0
Open File

Я действительно хочу синхронизировать файл ..

Спасибо!

Ответы [ 2 ]

0 голосов
/ 03 мая 2019

просто замените эту строку

  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'
0 голосов
/ 03 мая 2019

Пожалуйста, в следующий раз предоставьте более подробную информацию об ошибке для каждой консоли или 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'
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...