0% found this document useful (0 votes)
3 views7 pages

Add Firebase To Your Android Project - Evernote

Uploaded by

Carlos Bermudez
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views7 pages

Add Firebase To Your Android Project - Evernote

Uploaded by

Carlos Bermudez
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 7

https://firebase.google.

com/docs/android/setup

Add Firebase to your Android project

Add Firebase to your Android project


Prerequisites
Install or update Android Studio to its latest version.
Make sure that your project meets these requirements:
Targets API level 16 (Jelly Bean) or laterUses Gradle 4.1 or later
Uses Jetpack (AndroidX), which includes meeting these version requirements:
com.android.tools.build:gradle v3.2.1 or latercompileSdkVersion 28 or later
Set up a physical device or use an emulator to run your app.
Note that Firebase SDKs with a dependency on Google Play services require the device or emulator to
have Google Play services installed.
Sign into Firebase using your Google account.
If you don't already have an Android project and just want to try out a Firebase product, you can download
one of our quickstart samples.
You can connect your Android app to Firebase using one of the following options:
Option 1: (recommended) Use the Firebase console setup workflow.
Option 2: Use the Android Studio Firebase Assistant (may require additional configuration).

Option 1: Add Firebase using the Firebase console


Adding Firebase to your app involves tasks both in the Firebase console and in your open Android project
(for example, you download Firebase config files from the console, then move them into your Android
project).

Step 1: Create a Firebase project


Before you can add Firebase to your Android app, you need to create a Firebase project to connect to your
Android app. Visit Understand Firebase Projects to learn more about Firebase projects.
Create a Firebase project

Step 2: Register your app with Firebase


To use Firebase in your Android app, you need to register your app with your Firebase project. Registering
your app is often called "adding" your app to your project.
Note: Visit Understand Firebase Projects to learn more about best practices and considerations for adding
apps to a Firebase project, including how to handle multiple build variants.
1. Go to the Firebase console.
2. In the center of the project overview page, click the Android icon (plat_android) or Add app to launch
the setup workflow.
3. Enter your app's package name in the Android package name field.
y pp p g p g
What's a package name, and where do you find it?

Make sure to enter the package name that your app is actually using. The package name value is case-
sensitive, and it cannot be changed for this Firebase Android app after it's registered with your
Firebase project.
4. (Optional) Enter other app information: App nickname and Debug signing certificate SHA-1.
How are the App nickname and the Debug signing certificate SHA-1 used within Firebase?
5. Click Register app.

Step 3: Add a Firebase configuration file


1. Add the Firebase Android configuration file to your app:
Click Download google-services.json to obtain your Firebase Android config file (google-
services.json).
Move your config file into the module (app-level) directory of your app.
What do you need to know about this config file?
2. To enable Firebase products in your app, add the google-services plugin to your Gradle files.
In your root-level (project-level) Gradle file (build.gradle), add rules to include the Google Services
Gradle plugin. Check that you have Google's Maven repository, as well.
In your module (app-level) Gradle file (usually app/build.gradle), apply the Google Services Gradle
plugin:

Step 4: Add Firebase SDKs to your app


1. Using the Firebase Android BoM, declare the dependencies for the Firebase products that you want to
use in your app. Declare them in your module (app-level) Gradle file (usually app/build.gradle).
By using the Firebase Android BoM, your app will always use compatible versions of the Firebase
Android libraries.
2. Sync your app to ensure that all dependencies have the necessary versions.
Getting a build failure about invoke-custom support and enabling desugaring? Here's how to fix it.
That's it! You can skip ahead to check out the recommended next steps.
If you're having trouble getting set up, though, visit the Android troubleshooting & FAQ.

Option 2: Add Firebase using the Firebase Assistant


The Firebase Assistant registers your app with a Firebase project and adds the necessary Firebase files,
plugins, and dependencies to your Android project — all from within Android Studio!
1. Open your Android project in Android Studio, then make sure that you're using the latest versions of
Android Studio and the Firebase Assistant:
Windows / Linux: Help > Check for updatesmacOS: Android Studio > Check for updates
2. Open the Firebase Assistant: Tools > Firebase.
3. 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.
Wh t d thi kfl d ?
What does this workflow do?
Click the button to add a desired Firebase product (for example, Add Analytics to your app).
4. Sync your app to ensure that all dependencies have the necessary versions.
5. In the Assistant pane, follow the remaining setup instructions for your selected Firebase product.
6. Add as many other Firebase products as you'd like via the Firebase Assistant!
Are you using Kotlin?
You can use the alternative Kotlin extensions (KTX) libraries which enable you to write beautiful and
idiomatic Kotlin code.
Do you want an easier way to manage library versions?
You can use the Firebase Android BoM to manage your Firebase library versions and ensure that your app
is always using compatible library versions.
That's it! Make sure to check out the recommended next steps.
If you're having trouble getting set up, though, visit the Android troubleshooting & FAQ.

Available libraries
This section lists the Firebase products supported for Android and their Gradle dependencies. Learn more
about these Firebase Android libraries:
Reference documentation (Java | Kotlin+KTX)
Firebase Android SDK GitHub repo
Note that when using the Firebase Android BoM, you don't specify individual library versions when you
declare Firebase library dependencies in build.gradle.
The Firebase Android library firebase-core is no longer needed. This SDK included the Firebase SDK for
Google Analytics.
Now, to use Analytics or a product that recommends adding Analytics (see table below), you need to
explicitly declare the Analytics dependency: com.google.firebase:firebase-analytics or
com.google.firebase:firebase-analytics-ktx.

Service or Product Gradle dependency Latest Add Analytics?


version

Firebase Android BoM com.google.firebase:fireb 28.2.0


(Bill of Materials) ase-bom
The latest Firebase BoM
version contains the
latest versions of
each Firebase Android
library. To learn which
library versions are
mapped to a specific
BoM version, review the
release notes for
h B M i
that BoM version.

AdMob com.google.android.gms: 20.2.0


play-services-ads

Analytics com.google.firebase:fireb 19.0.0


ase-analytics

App Distribution plugin com.google.firebase:fireb 2.1.3


ase-appdistribution-
gradle

App Indexing com.google.firebase:fireb 20.0.0


ase-appindexing

Authentication com.google.firebase:fireb 21.0.1


ase-auth

Cloud Firestore com.google.firebase:fireb 23.0.1


ase-firestore

Cloud Functions for com.google.firebase:fireb 20.0.0


Firebase Client SDK ase-functions

Cloud Messaging com.google.firebase:fireb 22.0.0


ase-messaging

Cloud Storage com.google.firebase:fireb 20.0.0


ase-storage

Crashlytics com.google.firebase:fireb 18.1.0


ase-crashlytics

Crashlytics NDK com.google.firebase:fireb 18.1.0


ase-crashlytics-ndk

Crashlytics plugin com.google.firebase:fireb 2.7.1


ase-crashlytics-gradle

Dynamic feature module com.google.firebase:fireb 16.0.0-beta01


support ase-dynamic-module-
support

Dynamic Links com.google.firebase:fireb 20.1.0


ase-dynamic-links
In-App Messaging com.google.firebase:fireb 20.0.0 (required)
ase-inappmessaging

In-App Messaging Display com.google.firebase:fireb 20.0.0 (required)


ase-inappmessaging-
display

Firebase installations com.google.firebase:fireb 17.0.0


ase-installations

Firebase ML Model com.google.firebase:fireb 24.0.0


Downloader API ase-ml-
modeldownloader

Performance Monitoring com.google.firebase:fireb 20.0.1


ase-perf

Performance Monitoring com.google.firebase:perf- 1.4.0


plugin plugin

Realtime Database com.google.firebase:fireb 20.0.0


ase-database

Remote Config com.google.firebase:fireb 21.0.0


ase-config

Google Play services com.google.gms:google- 4.3.8


plugin services

Deprecated libraries

Firebase ML Custom com.google.firebase:fireb 22.0.4


Model APIs ase-ml-model-interpreter

Firebase ML Vision APIs com.google.firebase:fireb 24.1.0


ase-ml-vision

Firebase ML: Image com.google.firebase:fireb 20.0.2


Labeling Model ase-ml-vision-image-
label-model

Firebase ML: Object com.google.firebase:fireb 19.0.6


Detection and Tracking ase-ml-vision-object-
Model detection-model
Firebase ML: Face com.google.firebase:fireb 20.0.2
Detection Model ase-ml-vision-face-model

Firebase ML: Barcode com.google.firebase:fireb 16.1.2


Scanning Model ase-ml-vision-barcode-
model

Firebase ML: AutoML com.google.firebase:fireb 18.0.6


Vision Edge API ase-ml-vision-automl

Firebase ML: Natural com.google.firebase:fireb 22.0.1


Language APIs ase-ml-natural-language

Firebase ML: Language com.google.firebase:fireb 20.0.8


Identification Model ase-ml-natural-language-
language-id-model

Firebase ML: Translate com.google.firebase:fireb 20.0.9


Model ase-ml-natural-language-
translate-model

Firebase ML: Smart Reply com.google.firebase:fireb 20.0.8


Model ase-ml-natural-language-
smart-reply-model

Next steps
Add Firebase services to your app:
Gain insights on user behavior with Analytics.
Set up a user authentication flow with Authentication.
Store data, like user information, with Cloud Firestore or Realtime Database.
Store files, like photos and videos, with Cloud Storage.
Trigger backend code that runs in a secure environment with Cloud Functions.
Send notifications with Cloud Messaging.
Find out when and why your app is crashing with Crashlytics.
Learn about Firebase:
Visit Understand Firebase Projects to learn more about Firebase projects and best practices for
projects.
Visit Learn more about Android and Firebase if you have questions about concepts that are unfamiliar
or specific to Firebase and Android development.
Explore sample Firebase apps
Explore sample Firebase apps.
Get hands-on experience with the Firebase Android Codelab.
Learn more with the Firebase in a Weekend course.
Prepare to launch your app:
Set up budget alerts for your project in the Google Cloud Console.Monitor the Usage and billing
dashboard in the Firebase console to get an overall picture of your project's usage across multiple
Firebase services. Review the Firebase launch checklist.
Having trouble with Firebase and your Android project? Visit the Android troubleshooting & FAQ.
Rate and review

You might also like