Septik Argonot
Septik Argonot

Reputation: 235

All gms/firebase libraries must use the exact same version (mixing versions can lead to runtime crashes).Found versions 16.1.1 16.0.1 16.0.0 15.0.1

Trying to implement Firebase in my project but implementation 'com.google.firebase:firebase-core:16.0.1' ths line underlined. Please.

Thanks Mbuodile Obiosio but not work, I don't know.

apply plugin: 'com.android.application'

android {
    compileSdkVersion 27
    defaultConfig {
        applicationId "com.example.harun.basicmathquiz"
        minSdkVersion 15
        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 'com.android.support:appcompat-v7:27.1.1'
    implementation 'com.android.support.constraint:constraint-layout:1.1.2'
    implementation 'com.android.support:support-annotations:27.1.1'
    implementation 'com.android.support:design:27.1.1'
    implementation 'com.google.firebase:firebase-core:16.0.1'
    implementation 'com.google.firebase:firebase-database:16.0.1'

}

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

AND

// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {

    repositories {
        google()
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.1.2'
        classpath 'com.google.gms:google-services:4.0.1'
        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

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

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

MY ERROR: All gms/firebase libraries must use the exact same version specification (mixing versions can lead to runtime crashes). Found versions 16.1.1, 16.0.1, 16.0.0, 15.0.1. Examples include com.google.firebase:firebase-analytics-impl:16.1.1 and com.google.firebase:firebase-analytics:16.0.1

Upvotes: 3

Views: 5545

Answers (3)

Bilal Khan
Bilal Khan

Reputation: 141

I am also faced with the same problem. My problem is solved by doing this add the following in Gradle

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

And in dependencies

 dependencies {
 .
 .
 .
    implementation ('com.google.firebase:firebase-database:16.0.1') {
        exclude group: "com.google.android.gms"
    }
}
apply plugin: 'com.google.gms.google-services'

Upvotes: 2

Mbuodile Obiosio
Mbuodile Obiosio

Reputation: 1543

You're mixing versions and that's why you're getting the error.

    apply plugin: 'com.android.application'

    android {
    compileSdkVersion 27
    defaultConfig {
        applicationId "com.example.harun.basicmathquiz"
        minSdkVersion 15
        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 'com.android.support:appcompat-v7:27.1.1'
    implementation 'com.android.support:support-annotations:27.1.1'
    implementation 'com.android.support:design:27.1.1'
    implementation 'com.android.support.constraint:constraint-layout:1.1.2'
    implementation 'com.google.firebase:firebase-core:16.0.1'
    implementation 'com.google.firebase:firebase-database:16.0.1'    
 }

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

Don't forget to update the top level build.gradle file with

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

Upvotes: 1

Peter Haddad
Peter Haddad

Reputation: 80934

Upgrade the google-service plugin in the top level gradle file, to avoid the mixing version error:

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

https://bintray.com/android/android-tools/com.google.gms.google-services/

Upvotes: 2

Related Questions