Firebase is a mobile platform that helps you quickly develop high-quality apps, grow your user base, and earn more money. Here is the code you can use to implement Firebase in an Android app:
- Add Firebase to your Android project:
- Go to the Firebase console and click “Add project.”
- Follow the on-screen instructions to create a new project.
- Click “Add Firebase to your Android app” and enter your app’s package name.
- Download the config file and move it to your app’s module root directory.
- Add the config file to your project:
- In Android Studio, open the project’s “build.gradle” file and add the following line to the dependencies section:
implementation 'com.google.firebase:firebase-core:17.4.3'
- Sync the project with the gradle file by clicking “Sync Now.”
- Initialize Firebase in your app:
- In your app’s main activity, add the following code to initialize Firebase:
FirebaseApp.initializeApp(this);
That’s it! You have now successfully implemented Firebase in your Android app. You can then use Firebase’s various features and services, such as analytics, authentication, and real-time database, in your app.