In my project it failed to add “firebase” to android studio

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP



In my project it failed to add “firebase” to android studio



I was adding firebase to my project as documented in the official website.



In the 4th step it says to add compile 'com.google.firebase:firebase-core:16.0.0'.


compile 'com.google.firebase:firebase-core:16.0.0'



But trying to synch gradle I would get errors:



image



and by trying to download them (install repository abd synch project) I would get this error:


install repository abd synch project



image



here is my gradle dependencies:


dependencies
implementation 'com.google.firebase:firebase-core:16.0.1'
compile fileTree(dir: 'libs', include: ['*.jar'])
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2',
exclude group: 'com.android.support', module: 'support-annotations'
)

compile 'com.google.android.gms:play-services-gcm:15.0.1'
compile 'com.google.android.gms:play-services-location:15.0.1'
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:multidex:1.0.2'
compile 'com.android.support:appcompat-v7:26.1.0'
compile 'com.google.firebase:firebase-auth:11.6.2'
compile 'com.google.android.gms:play-services-auth:15.0.1'
compile 'com.google.code.gson:gson:2.7'
compile('io.socket:socket.io-client:1.0.0')
// excluding org.json which is provided by Android
exclude group: 'org.json', module: 'json'

compile 'com.onesignal:OneSignal:3.6.5'
compile 'com.android.volley:volley:1.0.0'
testCompile 'junit:junit:4.12'



this answer did not work either:
this



update



My project-level gradle:


buildscript
repositories
jcenter()
google()

dependencies
classpath 'com.android.tools.build:gradle:3.0.1'
classpath 'com.google.gms:google-services:4.0.1'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files



allprojects
repositories
jcenter()
maven url 'https://maven.google.com'
mavenCentral()
google()






again read plz firebase.google.com/docs/android/setup?authuser=0
– Ashvin solanki
Aug 8 at 8:28





Not an answer but use implementation instead of compile.
– moo cow
Aug 8 at 8:36


implementation


compile





Have you added apply plugin: 'com.google.gms.google-services' at the end of your build.gradle file? I cannot see it in your code.
– Alex Mamo
Aug 8 at 9:49


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




4 Answers
4



Upgrade the following:


implementation 'com.google.firebase:firebase-auth:11.6.2'



into this:


implementation 'com.google.firebase:firebase-auth:16.0.2'



Add google service plugin version 4.0.1 and google() repo in top level gradle file:


4.0.1


google()


buildscript
// ...
dependencies
// ...
classpath 'com.google.gms:google-services:4.0.1' // google-services plugin



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






I had them all, see my post update. I changed 11.6.2 to 16.0.2 but the same errors again.
– hsbr13
Aug 8 at 8:42



Use same versions of firebase services to avoid conflicts.
Refer https://firebase.google.com/docs/android/setup
To solve your problem.





I use the exact codes
– hsbr13
Aug 12 at 14:35



Before you proceed, clean and rebuild your project.



Then at app/build.gradle,



add apply plugin: 'com.google.gms.google-services'
like the code snippet down below.


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


android
// ...


dependencies
// ...


// ADD THIS AT THE BOTTOM
apply plugin: 'com.google.gms.google-services'



And make sure all the library used are as here.



Hope it helps!





I cannot clean project:Error:Could not resolve all files for configuration ':app:debugCompileClasspath'. > Could not find com.google.android.gms:play-services-measurement-base:11.6.2.
– hsbr13
Aug 12 at 14:33





@hsbr13 skip it, and follow my code
– Angus Tay
Aug 12 at 14:34





I had your code snippet already
– hsbr13
Aug 12 at 14:36





@hsbr13 did you apply the plugin? Can update your code at the question?
– Angus Tay
Aug 12 at 14:37





@hsbr13 see properly,at app/build.gradle, add the apply plugin to the bottom after dependencies
– Angus Tay
Aug 12 at 14:39



Add firebase-core to your dependencies block:


firebase-core


implementation 'com.google.firebase:firebase-core:16.0.1'



The Firebase SDK release notes for the June 12 release explain:



Your app gradle file now has to explicitly list
com.google.firebase:firebase-core as a dependency for Firebase
services to work as expected.



It's also safer to list google() first in repository lists:


google()


repositories
google()
jcenter()
...





same error keep happening
– hsbr13
Aug 12 at 14:33





Did you also change firebase-auth:11.6.2 to use a new version, e.g. 16.0.2?
– Bob Snyder
Aug 12 at 22:33


firebase-auth:11.6.2


16.0.2






By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Popular posts from this blog

Firebase Auth - with Email and Password - Check user already registered

Dynamically update html content plain JS

How to determine optimal route across keyboard