Home » Android » Google Play Services Version Conflict in Gradle Building

Google Play Services Version Conflict in Gradle Building

Posted by: admin November 1, 2017 Leave a comment

Questions:

I want to use Firebase Cloud Messaging in my App. Based on official documentation of Firebase I do this:

apply plugin: 'com.android.application'

android {
    compileSdkVersion 26
    buildToolsVersion '26.0.2'
    useLibrary 'org.apache.http.legacy'

    defaultConfig {
        minSdkVersion 16
        targetSdkVersion 18
        versionCode 3
        versionName "4.0"

    }

    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {

    compile 'com.google.firebase:firebase-core:11.4.2'
    compile 'com.google.firebase:firebase-messaging:11.4.2'

    compile "com.android.support:appcompat-v7:26.1.0"
    compile "com.android.support:design:26.1.0"
    compile files('libs/libGoogleAnalyticsServices.jar')
}

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

And this is project level Gradle file:

// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
    repositories {
        maven { url 'https://maven.google.com'  }
        jcenter()
    }
    dependencies {
        classpath 'com.google.gms:google-services:3.1.1'
        classpath 'com.android.tools.build:gradle:3.0.0-rc2'
    }
}

allprojects {
    repositories {
        maven { url 'https://maven.google.com'  }
        jcenter()

        flatDir {
            dirs 'libs'
        }
    }
}

But when i build the project allways get this error on the one of Firebase imports:

compile ‘com.google.firebase:firebase-core:11.4.2’

All gms/firebase libraries must use the exact same version specification(mixing versions can lead to runtime crashes).Found
versions 11.4.2, 10.0.1. Examples include
com.google.android.gms:play-services-basement:11.4.2 and
com.google.android.gms:play-services-base:10.0.

It seems Google Play Services reads its configuration and versions from another source because when i delete this lines:

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

and

classpath 'com.google.gms:google-services:3.1.1'

Project behave the same and it seems this lines doesnt any effect on project.

IMPORTANT: Also i check app.iml file and found some of Google Play Related entries has different versions than 11.4.2 that i want. if i remove app.iml file Android Studio recreate it and add the same versions. like these ones:

<orderEntry type="library" name="com.google.android.gms:play-services-location-10.0.1" level="project" />

<orderEntry type="library" name="com.google.android.gms:play-services-base-10.0.1" level="project" />

These two should also be 11.4.2 version because i use lates version of Google Play Services! And it seems this is the source of my problem.

I updated everything from Android SDK Manager and it doesnt fix the problem. this is for two days im struggling with this problem and cant build my project.

if i change firebase versions my problem will solve but i need latest versions and according to firebase documentation it should work:

compile 'com.google.firebase:firebase-core:10.0.1'
compile 'com.google.firebase:firebase-messaging:10.0.1'

What is the problem? Please Help me.

Answers: