Setup the android studio with firebase in react-native

Setup the android studio with firebase in react-native:

Here we are going to discuss “Setup the android studio with firebase in react-native” which is a next lesson of firebase integration, as well as you find the first lesson here- which is a first part of firebase setup.

Firebase flow –

Step 1:

Now we start with plugin setup and there is a npm plugin which handles firebase, so first we need to install this plugin.

 npm install --save react-native-firebase 
  or you can 
 yarn add react-native-firebase

Step 2:

We need to link react-native-firebase to our project first. please run the following command in the root directory

react-native link react-native-firebase

Checking the Android Studio Configuration after firebase linking

Here we are going to check the dependency of app, so let’s start

Please check these lines in your build.gradle, if not added then add it

dependencies {
 implementation project(':react-native-firebase')
 implementation ""
 implementation ''
 implementation "" <-- 
 this line is important for using cloud messaging notification, so 
 it's important to add
 implementation 'me.leolin:ShortcutBadger:1.1.21@aar' // <-- Add this 
 line if you wish to use the badge on Android}

And please check this line at the bottom of this file(last line of the file)

apply plugin: ''
  • Got to your project level build.gradle file (path of this file is: android –> build.gradle )

And the file is look like this, check each line very carefully

buildscript {
ext {
  buildToolsVersion = "28.0.3"
  minSdkVersion = 16
  compileSdkVersion = 28
  targetSdkVersion = 28
  supportLibVersion = "28.0.0"
  googlePlayServicesVersion = "16.0.0" // Make Sure This line is added 
  over here only

repositories {

dependencies {
 // classpath ''
  classpath ''
  classpath '' // Make Sure This 
  line is added over here only

allprojects {
 repositories {

maven {
// All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
url "$rootDir/../node_modules/react-native/android"  // Make Sure This block is added over here only

Note: make sure google() is always above the jcenter()

  • Now you need to make some changes in your android/app/src/main/AndroidManifest.xml file
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission  android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
<uses-permission android:name="android.permission.VIBRATE" />

 <!-- start of firebase messaging services -->

<service android:name="io.invertase.firebase.messaging.RNFirebaseMessagingService">
<action android:name="" />
<service android:name="io.invertase.firebase.messaging.RNFirebaseInstanceIdService">
<action android:name=""/>

<!-- end of firebase messaging services -->
  • As well as add the RNFirebaseMessagingPackage to your android/app/src/main/java/com/[app name]/
 // for firebase dependencies
import io.invertase.firebase.RNFirebasePackage;
import io.invertase.firebase.messaging.RNFirebaseMessagingPackage; // <-- Add this line
import io.invertase.firebase.notifications.RNFirebaseNotificationsPackage; // <-- Add this line
//package override definition
protected List<ReactPackage> getPackages() {
return Arrays.<ReactPackage>asList(
new MainReactPackage(),
new RNFirebasePackage(),
new RNFirebaseMessagingPackage(), // <-- Add this line
new RNFirebaseNotificationsPackage(), // <-- Add this line 

You can find my post on medium click here,  please follow me on medium as well.

Android setup is completed now.

you can find the 3 part of this tutorial, here – NEXT , please click on next to find the next part of this tutorial.

If have any query/issue, please feel free to ask.

Happy Coding Guys.

Related Post

Leave a Reply

Your email address will not be published. Required fields are marked *