Build Gradle Dependencies Version Conflict

Asked

Viewed 371 times

0

I’m trying to use Firebase in my application, but it’s giving dependency error in Gradle.

Build.Radle (App)

apply plugin: 'com.android.application'

apply plugin: 'kotlin-android'

apply plugin: 'kotlin-android-extensions'

android {
    compileSdkVersion 27
    defaultConfig {
        applicationId "com.juny.tinderx"
        minSdkVersion 19
        targetSdkVersion 27
        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-jre7:$kotlin_version"
    implementation 'com.android.support:appcompat-v7:27.1.1'
    implementation 'com.android.support.constraint:constraint-layout:1.0.2'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'com.android.support.test:runner:1.0.1'
    androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'
    implementation 'com.google.firebase:firebase-auth:11.8.0'
    implementation 'com.google.firebase:firebase-database:11.8.0'
}

apply plugin: 'com.google.gms.google-services'

Build.Radle(project)

buildscript {
   ext.kotlin_version = '1.2.30'
   repositories {
       google()
       jcenter()
   }
   dependencies {
       classpath 'com.android.tools.build:gradle:3.1.1'
       classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
       classpath 'com.google.gms:google-services:3.2.0'
       // NOTE: Do not place your application dependencies here; they belong
       // in the individual module build.gradle files
   }
}

allprojects {
    repositories {
        google()
        jcenter()
        maven {
            url "https://maven.google.com" // Google's Maven repository
        }

    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}

That is the Mistake that:

inserir a descrição da imagem aqui

  • Post your full Gradle!

  • I posted the full Gradle. Grateful!

  • Probably some library you are using has been compiled with an older version of the google support libraries. We need to find out which has this dependency. For this I’ll ask you for more help. Open a grdle terminal and type: ./gradlew app:dependencies then post in ask the result.

  • The dependency tree exceeds the character limit, so I sent it to a link: https://pastebin.com/i4FSe58M

  • Who is using the old support library is firebase! Are you using the newer version? I saw that in your Gradle is the 11.8, which is the youngest, but in the dependencies appears 11.6!!! Are you sure you are using this Radle? That there is nothing lost out there using older version? etc.

2 answers

1

In its dependency tree there are references to older versions of firebase, which refer to play-services-based:11.6.0 which use the older support library (25.2). They should refer to version 11.8.0 which is expected to :-) use version 27.1.1 of the support library:

+--- com.google.firebase:firebase-auth:11.6.0
|    +--- com.google.android.gms:play-services-base:11.6.0
|    |    +--- com.google.android.gms:play-services-basement:11.6.0
|    |    |    +--- com.android.support:support-v4:25.2.0
|    |    |    |    +--- com.android.support:support-compat:25.2.0 -> 27.1.1 (*)
|    |    |    |    +--- com.android.support:support-media-compat:25.2.0
|    |    |    |    |    +--- com.android.support:support-annotations:25.2.0 -> 27.1.1
|    |    |    |    |    \--- com.android.support:support-compat:25.2.0 -> 27.1.1 (*)

You need to ensure that you are using the newest Firebase library (and others, if applicable) so that everyone internally uses the latest version of the support library.

There are ways to force the use of the latest version, both with generic script and manually (an example where this is needed is in the integration with the Facebook library that is never in the newer version of the support library), however, as in your case your project is starting, still without many dependencies, the best option is to always ensure that you are using all the newer versions of the libraries involved, even more when they are from Google itself.

0

In your Radle dependencies put this:

//Resolve conflitos da lib support
configurations.all {
    resolutionStrategy.eachDependency { DependencyResolveDetails details ->
        if (details.requested.group == 'com.android.support') {
            details.useVersion "27.1.0"
        }
    }
}

Browser other questions tagged

You are not signed in. Login or sign up in order to post.