1

Currently, I am working on an android chat application. I want to add FCM in my app. But I am always getting this gradle error. From what I have read, the firebase auth, database and messaging dependency version should match. I have tried every version, still, the same error occurs.

Snapshot of problem

AskNilesh
  • 67,701
  • 16
  • 123
  • 163
Hasan
  • 13
  • 1
  • 3

4 Answers4

1

To solve this, please change the following line of code:

com.google.firebase:firebase-auth:16.0.1

to

com.google.firebase:firebase-auth:16.0.2

and add:

com.google.firebase:firebase-core:16.0.1

Which is mandatory now. Don't also forget to add:

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

At the end of your file and the following line of code:

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

Into your build.gradle file (Project).

PS. If you are using Firebase-UI auth, add also this line of code:

com.firebaseui:firebase-ui-auth:4.0.1
Ashish
  • 6,791
  • 3
  • 26
  • 48
Alex Mamo
  • 130,605
  • 17
  • 163
  • 193
0

You must have forgotten to add google() // Google's Maven repository in build.gradle.

allprojects {
   // ...
   repositories {
       // ...
       google() // Google's Maven repository
   }
}

Here is the comment from firebase docs:

// Getting a "Could not find" error? Make sure you have

// added the Google maven respository to your root build.gradle

Here is the reference: link

Community
  • 1
  • 1
mark922
  • 1,136
  • 2
  • 11
  • 20
0

Add Maven to your project.gradle in repositories LIKE THIS

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

Late post, but will help to someone... Change your project level build.gradle file

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

    }
}

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

Make changes in app-level build.gradle file

dependencies {
    implementation 'com.google.android.gms:play-services:+'
    implementation 'com.google.firebase:firebase-messaging:17.3.4'
    implementation 'com.android.volley:volley:1.1.1'
    implementation 'com.squareup.picasso:picasso:2.71828'
    //implementation 'com.google.firebase:firebase-ads:15.0.1'
    implementation 'com.google.firebase:firebase-ads:17.1.2'
    implementation 'com.google.android.gms:play-services-ads:15.0.1'
    implementation 'com.google.firebase:firebase-core:16.0.8'
    implementation 'com.google.firebase:firebase-database:16.1.0'
}
msolak
  • 21
  • 3