how to solve version conflict error in android?


Keywords:android 


Question: 

apply plugin: 'com.android.application'
apply plugin: 'com.google.gms.google-services'
android {
    compileSdkVersion 27
    buildToolsVersion "27.0.3"
    defaultConfig {
        applicationId "xxxxxxxxxxxxxxxxxxx"
        minSdkVersion 19
        targetSdkVersion 27
        versionCode 20
        versionName '6.7'
        multiDexEnabled true
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
        useLibrary 'org.apache.http.legacy'
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
        dexOptions {
            javaMaxHeapSize "4g"

        }
    }
    productFlavors {
    }
}

dependencies {
    compile fileTree(include: ['*.jar'], dir: 'libs')
    compile files('libs/droidText.0.2.jar')
    compile files('libs/mail.jar')
    compile files('libs/activation.jar')
    compile files('libs/additionnal.jar')
    // compile files('libs/gson-2.2.2.jar')
    androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
        exclude group: 'com.android.support', module: 'support-annotations'
    })
    testCompile 'junit:junit:4.12'
    compile 'com.loopj.android:android-async-http:1.4.9'
    compile 'com.squareup.picasso:picasso:2.5.2'
    compile 'com.squareup.picasso:picasso:2.5.2'
    compile 'com.mcxiaoke.volley:library-aar:1.0.0'
    compile 'com.android.support:recyclerview-v7:27.1.0'
    compile 'com.android.support:appcompat-v7:27.1.0'
    compile 'com.android.support:design:27.1.0'
    compile 'com.android.support:support-core-utils:27.1.0'
    compile 'com.android.support:support-compat:27.1.0'
    compile 'com.android.support:multidex:1.0.1'
    // Glide image library
    compile 'com.google.firebase:firebase-messaging:11.0.4'
    compile 'com.google.android.gms:play-services-location:11.6.0'
    compile 'com.google.android.gms:play-services-places:11.6.0'
    compile 'com.google.android.gms:play-services-maps:11.6.0'
     //implementaion 'com.google.android.gms:play-services:9.0.0'
    compile 'com.google.code.gson:gson:2.6.2'
    compile 'com.squareup.retrofit2:retrofit:2.0.2'
    compile 'com.squareup.retrofit2:converter-gson:2.0.2'
    compile 'com.squareup.retrofit:retrofit:1.9.0'
    compile 'com.squareup.picasso:picasso:2.5.2'
    compile 'com.squareup.retrofit2:retrofit:2.0.0-beta4'
    compile 'com.squareup.retrofit2:adapter-rxjava:2.0.0-beta4'
    compile 'com.squareup.retrofit2:converter-gson:2.0.0-beta4'
    compile 'com.wdullaer:materialdatetimepicker:2.3.0'
    compile 'com.github.bumptech.glide:glide:3.7.0'
    testCompile 'junit:junit:4.12'
    compile 'org.apache.httpcomponents:httpclient-android:4.3.5.1'
    compile('org.apache.httpcomponents:httpmime:4.3') {
        exclude module: "httpclient"
    }
    compile('com.google.code.gson:gson:2.2.2') {
        exclude module: "com.google.code.gson"
    }
}
allprojects {
    repositories {
        jcenter()
        maven {
            url "https://maven.google.com"
        }
    }
}
android {
    packagingOptions {
        exclude 'META-INF/DEPENDENCIES.txt'
        exclude 'META-INF/LICENSE.txt'
        exclude 'META-INF/NOTICE.txt'
        exclude 'META-INF/NOTICE'
        exclude 'META-INF/LICENSE'
        exclude 'META-INF/DEPENDENCIES'
        exclude 'META-INF/notice.txt'
        exclude 'META-INF/license.txt'
        exclude 'META-INF/dependencies.txt'
        exclude 'META-INF/LGPL2.1'
        exclude 'META-INF/ASL2.0'
        exclude '.idea/compiler.xml'
    }
    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_7
        targetCompatibility JavaVersion.VERSION_1_7
    }

    defaultConfig {
        multiDexEnabled true

    }

}

Here I have defined Gradle with firebase and play service related libraries. Previously I used Firebase 9.0.0 version, now that is not taking firebase key. So I have updated to new version, then started getting below issue. First I updated firebase library only, but error is shown like playservice and firebase must maintain the same version. Problem is playservice related gradle change time. (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 ) or updating the version of com.google.android.gms to 9.0.0. )


1 Answer: 

The google-service plugin problem is because you're using not the same version for firebase and google play service with:

compile 'com.google.firebase:firebase-messaging:11.0.4'
compile 'com.google.android.gms:play-services-location:11.6.0'
compile 'com.google.android.gms:play-services-places:11.6.0'
compile 'com.google.android.gms:play-services-maps:11.6.0'

it should be:

compile 'com.google.firebase:firebase-messaging:11.6.0'
compile 'com.google.android.gms:play-services-location:11.6.0'
compile 'com.google.android.gms:play-services-places:11.6.0'
compile 'com.google.android.gms:play-services-maps:11.6.0'

Then, you also need to move the apply plugin: 'com.google.gms.google-services' to the bottom of your build gradle like this:

apply plugin: 'com.android.application'
android {
   ...
}

   ...

dependencies {
   ...
}

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

You also need to only use only one version of dependencies. In your project you're using:

compile 'com.google.code.gson:gson:2.6.2'

compile('com.google.code.gson:gson:2.2.2') {
    exclude module: "com.google.code.gson"
}

that is a redundant. You need to use only one:

compile 'com.google.code.gson:gson:2.6.2'

Last, you don't need to add the following:

compile files('libs/droidText.0.2.jar')
compile files('libs/mail.jar')
compile files('libs/activation.jar')
compile files('libs/additionnal.jar')

because the following line is already included all of them:

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