Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cant add firebase to android app

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?

like image 242
lee huang Avatar asked Jun 06 '16 03:06

lee huang


People also ask

How do I connect my Android app to Firebase?

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.

Can't connect to Firebase in Android Studio?

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 not working?

Is Firebase down today? According to its status page Firebase is currently up.

How to add firebase to Android project in Android Studio?

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.

How to connect app to Firebase Cloud Firestore?

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.

How to send verification to Firebase console from Android app?

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.

Why am I getting a build failure when adding a firebase SDK?

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.


3 Answers

  1. Go to Tools->Android->SDK Manager.
    Android Studio settings
  2. In SDK Tools tab update 'Google Play services' and 'Google Repository' to minimum 30 and 28 respectively.
  3. Sync project with Gradle files.
like image 92
Mayur Avatar answered Oct 17 '22 03:10

Mayur


Update following SDK tools packages from SDK manager will solve your problem

See Video How To Fix

enter image description here

enter image description here

like image 30
Munish Kapoor Avatar answered Oct 17 '22 05:10

Munish Kapoor


update to 9.0.2 it will resolve all the problems.

Also update Google Repository and Google Play Services.

like image 28
Senghani Maulik Avatar answered Oct 17 '22 04:10

Senghani Maulik