Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

all gms/firebase libaries must use the exact same version. Found versions 15.1.0, 15.0.2, 15.0.1, 15.0.0.

Trying to implement Firebase in my project.

Gradle file:

apply plugin: 'com.android.application'

android {
compileSdkVersion 27
defaultConfig {
    applicationId "com.ghaleh.myapplication"
    minSdkVersion 16
    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-media-compat:27.1.1'
implementation 'com.android.support:support-v4:27.1.1'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-  core:3.0.2'
implementation 'com.google.firebase:firebase-messaging:15.0.2'
}
apply plugin: 'com.google.gms.google-services'

And I'm getting this error:

All gms/firebase libraries must use the exact same version specification (mixing versions can lead to runtime crashes). Found versions 15.1.0, 15.0.2, 15.0.1, 15.0.0. Examples include com.google.firebase:firebase-iid:15.1.0 and com.google.android.gms:play-services-measurement-base:15.0.2

According to Google's Maven Repository the latest version of firebase-messaging is 15.0.2 and I'm getting error for firebase-iid:15.1.0 So I cannot upgrade the firebase-messaging to a higher version or implement the firebase-iid:15.1.0 to match the versions.

I've already tried other solutions recommended here: 1, 2, 3 but non of them were useful.

I've also tried this (however it doesn't seem to be a proper solution):

implementation ('com.google.firebase:firebase-messaging:15.0.2') {
    exclude group: "com.google.android.gms"
}

and I get this error:

Error:Execution failed for task ':app:transformDexArchiveWithExternalLibsDexMergerForBazaarDebug'.
java.lang.RuntimeException: com.android.builder.dexing.DexArchiveMergerException: Unable to merge dex

Thanks in advance.

like image 641
Amir Avatar asked May 06 '18 07:05

Amir


1 Answers

You need to update google-service plugin to use:

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

to be able to avoid those errors, also upgrade to android studio 3.1

If you're not using Android Studio 3.1 to develop your app, you will need to upgrade in order to get the correct version checking behavior within the IDE.

more information and steps to follow:

Announcing new SDK versioning

Compilation failed to complete:Program type already present: com.google.android.gms.internal.measurement.zzabn

like image 56
Peter Haddad Avatar answered Nov 01 '22 05:11

Peter Haddad