I want to add firebase to my app for push notifications. I have followed the firebase docs and have done this:
root/app/build.gradle :
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.1.1'
compile 'com.google.firebase:firebase-core:9.0.2'
}
apply plugin: 'com.google.gms.google-services'
root/build.gradle :
dependencies {
classpath 'com.android.tools.build:gradle:1.5.0'
classpath 'com.google.gms:google-services:3.0.0'
}
I have also added the google-services.json in root/app
dir.
On trying to sync the project, there is an error :
Error:(25, 13) Failed to resolve: com.google.firebase:firebase-core:9.0.2
I dont understand why this error is present. How can I resolve it?
Open the Firebase Assistant: Tools > Firebase. In the Assistant pane, choose a Firebase product to add to your app. Expand its section, then click the tutorial link (for example, Analytics > Log an Analytics event). Click Connect to Firebase to connect your Android project with Firebase.
You will receive this error if you have open different accounts between Android Studio and Firebase. Because the Firebase assistant attempts to contact the Firebase service with your account registered in Android Studio. You can resolve this error by selecting the Add account option in Android Studio.
Is Firebase down today? According to its status page Firebase is currently up.
There are two ways to add firebase to any Android app: Using Firebase Assistant. Below are the steps to include Firebase to Android project in Android studio: Create a new project in the firebase by clicking on the Add project. Now open the android studio and click on Tools in the upper left corner.
Inside that column Navigate to Firebase Cloud Firestore. Click on that option and you will get to see two options on Connect app to Firebase and Add Cloud Firestore to your app. Click on Connect now option and your app will be connected to Firebase. After that click on the second option and now your App is connected to Firebase.
Now download the google-services.json file and place it in the root directory of the android app. Now add the following in the project. Adding the sdk in the project. ... Now Sync the gradle by clicking on sync now. After adding the above code (sdk), run the app to send the verification to the Firebase console.
Gradle builds that use Android Gradle plugin (AGP) v4.2 or earlier need to enable Java 8 support. Otherwise, these Android projects get a build failure when adding a Firebase SDK. Add the listed compileOptions from the error message to your app-level build.gradle file. Increase the minSdkVersion for your Android project to 26 or above.
Update following SDK tools packages from SDK manager will solve your problem
See Video How To Fix
update to 9.0.2 it will resolve all the problems.
Also update Google Repository and Google Play Services.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With