I keep receiving a gradle sync error when trying t

2019-08-25 03:02发布

问题:

Update on Question : after speaking to the creator of the Tutorial I was following trying to create Live Chat using Firebase. He told me to Change in your Gradle compile 'com.google.firebase:firebase-core:9.4.0' compile 'com.google.firebase:firebase-database:9.4.0'

If this is the case, what do I need to change in my dependencies in order to use this 9.4.0 version?

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

This is the Error that I am getting now:

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.

回答1:

To use version 11.2.0 of the Firebase libraries with FirebaseUI 2.3.0, you must update your dependencies as follows:

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'

The addition of firebase-auth and play-services-auth is required because a version of FirebaseUI that is built with 11.2.0 is not yet available. This is explained in the FirebaseUI documentation.

You should also make these changes:

compileSdkVersion 26
buildToolsVersion "26.0.1"

The requirement for compileSdkVersion 26 is in the 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)



回答2:

Since you are using com.android.support:customtabs:26.0.1 you have to add in the repositories the "https://maven.google.com" endpoint.
All the support libraries since 25.4.0 are in the google maven repo as described here.

In your case something like;

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

Also if you want to add the latest Firebase libraries v. 11.2.0 you have to add the same repo as described here.



回答3:

You have to go to SDK Manager and download SDK Platform files for API 26 (Android 8.0) if not already installed. Then update all the support library files to version 26.0.1 like compile 'com.android.support:design:25.3.1' to compile 'com.android.support:design:26.0.1' and so on. You also need to change compileSdkVersion 25 to 26, buildToolsVersion "25.0.2" to "26.0.1" and targetSdkVersion 25 to 26. And add maven "https://maven.google.com" to repositories

Firebase is looking for support libraries of version 26.0.1. And since that is either not installed or your buildToolsVersion and compileSdkVersion are not pointing to it, gradle is unable to resolve them.