5

My project was working fine until one day, because of no reason (I didn't change anything), gradle started giving this strange error:

Program type already present: com.google.android.gms.internal.measurement.zzabo

At the time of this error my project level gradle was like this:

buildscript {
    repositories {
        jcenter()
        maven {
            url 'https://maven.google.com'
            // Alternative URL is 'https://dl.google.com/dl/android/maven2/'
        }
        maven { url 'https://plugins.gradle.org/m2/'}
        maven { url 'https://maven.fabric.io/public' }
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.1.2'
        classpath 'com.google.gms:google-services:4.0.0'
        classpath 'io.fabric.tools:gradle:1.25.3'
        classpath 'gradle.plugin.com.onesignal:onesignal-gradle-plugin:0.8.1'
    }
}

allprojects {
    repositories {
        jcenter()
        maven {
            url 'https://dl.bintray.com/sayyam/maven'
        }
        maven {
            url "https://jitpack.io"
        }
        maven {
            url 'https://maven.google.com'
        }
    }
}

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

and this was my app level gradle:

apply plugin: 'com.android.application'
apply plugin: 'com.onesignal.androidsdk.onesignal-gradle-plugin'
apply plugin: 'io.fabric'

android {
    compileSdkVersion 27
    buildToolsVersion "27.0.3"

    dexOptions {
        javaMaxHeapSize "4g"
    }
    packagingOptions {
        exclude 'META-INF/rxjava.properties'
    }
    defaultConfig {
        applicationId "com.example"
        deviceCheck
        minSdkVersion 17
        targetSdkVersion 27
        versionCode 8
        versionName "1.0"
        vectorDrawables.useSupportLibrary = true
        multiDexEnabled true
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
}

dependencies {
    implementation fileTree(include: ['*.jar'], dir: 'libs')
    implementation 'com.google.firebase:firebase-invites:15.0.1'
    implementation 'com.google.firebase:firebase-core:15.0.2'
    implementation 'com.crashlytics.sdk.android:crashlytics:2.9.2'
    implementation 'com.google.android.gms:play-services-maps:15.0.1'
    implementation 'com.google.android.gms:play-services-location:15.0.1'
    implementation 'com.google.android.gms:play-services-places:15.0.1'
    implementation 'com.google.maps.android:android-maps-utils:0.5'
    implementation 'com.android.support:support-v13:27.1.1'
    implementation 'com.android.support:support-v4:27.1.1'
    implementation 'com.android.support:appcompat-v7:27.1.1'
    .....other dependencies.....
    testImplementation 'junit:junit:4.12'
}
apply plugin: 'com.google.gms.google-services'

I searched and found this answer on stackoverflow. Which says that this issue might be related to firebase dependency version and google-services plugin. So i updated google-services plugin version to 4.0.0 and firebase to its latest version 16.0.0. And as one could expect from gradle, it gave another error which seems to be related to firebase version 16.0.0.

Whenever i change firebase version to 16.0.0, apparently it tries to automatically upgrade google play services dependencies to 16.0.0 too. Which doesn't EVEN exist! It raises following gradle error:

Failed to resolve: com.google.android.gms:play-services-maps:16.0.0
Failed to resolve: com.google.android.gms:play-services-location:16.0.0 
Failed to resolve: com.google.android.gms:play-services-places:16.0.0   
Failed to resolve: com.google.android.gms:play-services-gcm:16.0.0  
Failed to resolve: com.google.android.gms:play-services-base:16.0.0 
Failed to resolve: com.google.android.gms:play-services-basement:16.0.0 
Failed to resolve: com.google.android.gms:play-services-measurement-base:16.0.0 
Failed to resolve: com.google.android.gms:play-services-tasks:16.0.0    
Failed to resolve: com.google.android.gms:play-services-stats:16.0.0
Failed to resolve: com.google.android.gms:play-services-ads-identifier:16.0.0

I have tried to force version of gms libraries using resolutionStrategy but to no avail. What should i do? What am I doing wrong?

NOTE: I didn't change play services libraries version explicitly, gradle seems to do it because of firebase.

EDIT: This problem can be solved by the solution given in this question, but still its not duplicate because in my case onesignal plugin was updating only gms libraries version and not firebase version. So anybody facing this problem won't search for keywords used in this question.

Qandeel Abbassi
  • 999
  • 7
  • 31
  • which firebase depedencies did u upgrade to 16.0.0? – Peter Haddad May 24 '18 at 17:15
  • firebase-core and firebase-invites..I have only these two in gradle – Qandeel Abbassi May 24 '18 at 17:16
  • 2
    Possible duplicate of [Highest firebase version code is used for compiling play services library too](https://stackoverflow.com/questions/50512955/highest-firebase-version-code-is-used-for-compiling-play-services-library-too) – Sam Stern May 24 '18 at 19:44
  • Yea it is, i didn't come across it because i wasn't even expecting it was related to onesignal as it was working fine and issue was appearing after updating firebase – Qandeel Abbassi May 24 '18 at 20:15
  • Also note that in my case the onesignal plugin was updating **gms** libraries version not **firebase** . So anybody facing this issue won't search for keywords used in [this](https://stackoverflow.com/questions/50512955/highest-firebase-version-code-is-used-for-compiling-play-services-library-too) question. – Qandeel Abbassi May 24 '18 at 20:26

1 Answers1

3

I believe you have run into the same issues as the poster of https://stackoverflow.com/a/50516114/7070704 with the same resolution.

Basically, the com.onesignal.androidsdk.onesignal-gradle-plugin plugin is forcing an uplift on your dependencies onto something which does not exist.

zfromg
  • 170
  • 9
  • Dude thanks alot! I wasn't even expecting that this issue might be related to that stupid plugin as it was working fine before. The issue resolved by updating the onesignal plugin version to 0.10.1... I also updated onesignal dependency to 3.9.1 – Qandeel Abbassi May 24 '18 at 20:10
  • 1
    also excluded firebase-messaging from onesignal as it was old and creating conflicts related to firebase-iid which is also included in firebase-invites. Added firebase-messaging separately with version 17.0.0 – Qandeel Abbassi May 24 '18 at 20:14