cant connect firebase to android studio

Solution 1:

  1. Add google service plugin

     plugins {
     id 'com.android.application'
     id 'com.google.gms.google-services'
     id 'com.onesignal.androidsdk.onesignal-gradle-plugin'
    

    }

  2. and also check build gradle project for google service dependency

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

Solution 2:

In Your build.gradle apply these plugins and libraries for adding firebase.

apply plugin: 'com.android.application'
apply plugin: 'com.google.gms.google-services'
apply plugin: 'com.google.firebase.crashlytics'


implementation platform('com.google.firebase:firebase-bom:26.0.0')
implementation 'com.google.firebase:firebase-analytics'
implementation 'com.google.firebase:firebase-messaging:23.0.0'
implementation 'com.google.firebase:firebase-crashlytics'
implementation 'com.google.firebase:firebase-analytics'

In your class path file please verify that you entered these lines properly inside dependecies tag;

classpath 'com.google.gms:google-services:4.3.10'
classpath 'com.google.firebase:firebase-crashlytics-gradle:2.8.1'

And Yes obviously make sure you have added JSON file of google under the app section of the Project file.