Unable to resolve dependency for ':app@debug/compileClasspath': Could not resolve com.google.firebase:firebase-messaging:17.1.0

旧时模样 提交于 2019-12-11 21:50:49

问题


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.


回答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



回答2:


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




回答3:


Add Maven to your project.gradle in repositories LIKE THIS

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


来源:https://stackoverflow.com/questions/51551190/unable-to-resolve-dependency-for-appdebug-compileclasspath-could-not-resolv

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!