Prerequisites
- A device running Android 2.3 (Gingerbread) or newer, and Google Play services 9.6.1 or newer
- The Google Repository from the Android SDK Manager
- Android Studio 1.5 or higher
If you don't have an Android Studio project already, you can download one of
our quickstart samples if you just want to try a
Firebase feature. If you're using a quickstart, remember to get the application
ID from the build.gradle
file in your project's module folder
(typically app/
), as you'll need this package name for the next step.
Add Firebase to your app
To add Firebase to your app you'll need a Firebase project and a Firebase configuration file for your app.
- Create a Firebase project in the Firebase console, if you don't already have one. If you already have an existing Google project associated with your mobile app, click Import Google Project. Otherwise, click Create New Project.
- Click Add Firebase to your Android app and follow the setup steps. If you're importing an existing Google project, this may happen automatically and you can just download the config file.
- When prompted, enter your app's package name. It's important to enter the package name your app is using; this can only be set when you add an app to your Firebase project.
- At the end, you'll download a
google-services.json
file. You can download this file again at any time. - If you haven't done so already, copy this into your project's module folder,
typically
app/
.
Add the SDK
If you would like to integrate the Firebase libraries into one of your own projects, you need to perform a few basic tasks to prepare your Android Studio project. You may have already done this as part of adding Firebase to your app.
First, add rules to your root-level build.gradle
file, to
include the google-services plugin:
buildscript {
// ...
dependencies {
// ...
classpath 'com.google.gms:google-services:3.0.0'
}
}
Then, in your module Gradle file (usually the app/build.gradle
), add the
apply plugin
line at the bottom of the file to enable the Gradle plugin:
apply plugin: 'com.android.application'
android {
// ...
}
dependencies {
// ...
compile 'com.google.firebase:firebase-core:9.6.1'
// Getting a "Could not find" error? Make sure you have
// the latest Google Repository in the Android SDK manager
}
// ADD THIS AT THE BOTTOM
apply plugin: 'com.google.gms.google-services'
You should also add the dependencies for the Firebase SDKs you want to use. We
recommend starting with com.google.firebase:firebase-core
, which provides Firebase Analytics
functionality. See the list of available libraries
below.
Available libraries
The following libraries are available for the various Firebase features.
Gradle Dependency Line | Service |
---|---|
com.google.firebase:firebase-core:9.6.1 | Analytics |
com.google.firebase:firebase-database:9.6.1 | Realtime Database |
com.google.firebase:firebase-storage:9.6.1 | Storage |
com.google.firebase:firebase-crash:9.6.1 | Crash Reporting |
com.google.firebase:firebase-auth:9.6.1 | Authentication |
com.google.firebase:firebase-messaging:9.6.1 | Cloud Messaging and Notifications |
com.google.firebase:firebase-config:9.6.1 | Remote Config |
com.google.firebase:firebase-invites:9.6.1 | Invites and Dynamic Links |
com.google.firebase:firebase-ads:9.6.1 | AdMob |
com.google.android.gms:play-services-appindexing:9.6.1 | App Indexing |
Next steps
Get hands-on experience using Firebase with the Firebase Android Codelab.