Version Conflict in Build Gradle Dependencies

0

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

  

Build.grad (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.grad (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
}
  

This is the Error that gives:

    
asked by anonymous 11.04.2018 / 17:18

2 answers

1

In your dependency tree there are references to older versions of firebase, which refer to play-services-basemente: 11.6.0 that use the older support library (25.2). They should reference 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) for everyone to use the latest version of the support library internally.

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

    
12.04.2018 / 19:55
0

In dependencies of your gradient 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"
        }
    }
}
    
12.04.2018 / 19:35