1

I'm trying to implement a couple of features of Firebase as following;

implementation 'com.google.firebase:firebase-core:16.0.4'
implementation 'com.google.firebase:firebase-messaging:16.0.4'
implementation 'com.google.firebase:firebase-database:16.0.4'
implementation 'com.google.firebase:firebase-crash:16.0.4'

implementation 'com.google.android.gms:play-services-analytics:16.0.4'

The problem is that gradle sync is failing with following errors;

Failed to resolve: com.google.firebase:firebase-core:17.0.2

Failed to resolve: com.google.firebase:firebase-messaging:17.0.2

Failed to resolve: com.google.firebase:firebase-database:17.0.2

Failed to resolve: com.google.firebase:firebase-crash:17.0.2

Failed to resolve: com.google.android.gms:play-services-analytics:17.0.2

Failed to resolve: com.google.android.gms:play-services-location:17.0.2

Failed to resolve: com.google.android.gms:play-services-base:17.0.2

These errors are very confusing as no where in build.gradle I'm neither hitting 17.0.2 version of Firebase nor play services. Any clue?

Ammar
  • 1,811
  • 5
  • 26
  • 60
  • Possible duplicate of [Failed to resolve: com.google.firebase:firebase-core:9.0.0](https://stackoverflow.com/questions/37310188/failed-to-resolve-com-google-firebasefirebase-core9-0-0) – Intsab Haider Oct 25 '18 at 13:10
  • You have a single module app or multiple modules app? Maybe a module of the project specifies that version or firebase in its gradle – Nicola Gallazzi Oct 25 '18 at 13:11
  • i@NicolaGallazzi it's a single module app. – Ammar Oct 25 '18 at 13:13
  • 1
    Firebase Crash doesn't exist anymore btw. It probably won't fix your issue but you should be using Crashlytics. – TheWanderer Oct 25 '18 at 13:16

2 Answers2

2

You need to update your top-level build.gradle to use the latest version of the google services plugin. It looks like you're using a very old one that still assumes that all the Firebase and Play dependencies must be the same version, which is no longer the case.

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

You should familiarize yourself with the latest integration instructions in the documentation, along with the latest versions of each dependency.

Also, you should stop using Firebase Crash Reporting and migrate to Crashlytics. Firebase Crash Reporting is decommissioned.

Doug Stevenson
  • 297,357
  • 32
  • 422
  • 441
1

This is how I have wired it up. See if this helps.

    buildscript {
        repositories {
            google()
            maven {
                url 'https://maven.google.com/'
                name 'Google'
            }

            jcenter()
        }
        dependencies {
            classpath 'com.android.tools.build:gradle:3.2.1'
            classpath 'com.google.gms:google-services:4.0.1'
        }
    }

    allprojects {
    repositories {
        google()
        jcenter()
    }
}

dependencies {

    //Firebase features
    implementation 'com.google.firebase:firebase-core:16.0.4'
    implementation 'com.google.firebase:firebase-config:16.1.0'
    implementation 'com.google.firebase:firebase-crash:16.2.1'
    implementation 'com.google.firebase:firebase-messaging:17.3.4'

    implementation('com.crashlytics.sdk.android:crashlytics:2.9.5@aar') {
        transitive = true
    }
    implementation('com.crashlytics.sdk.android:answers:1.4.1@aar') {
        transitive = true
}
}

    apply plugin: 'com.google.gms.google-services'
Novjean
  • 51
  • 1
  • 5