You're viewing the legacy docs. They are deprecated as of May 18, 2016.
These docs are for version 2.5.2 and below of the Java SDK. Go to our current docs, or see our Android migration guide.

Java Android Guide

Installation & Setup

In this document, we'll guide you though adding the Firebase Java/Android SDK to your project.

Create an account

First sign up for a free account. A new Firebase app will be created for you with a unique URL ending in You'll use this URL to store and sync data.

Within the App Dashboard you can create, manage and delete Firebases. Clicking on a specific Firebase lets you view and modify your app's data in realtime. In your app dashboard, you can also set Security and Firebase Rules, manage your app's authentication, deploys, and view analytics.

Install Firebase

To use Firebase in your Android application you can add a dependency to Gradle or Maven in your project or download the latest SDK.

With version 1.1, Firebase has different SDKs for Android and the JVM. This sections handles Firebase for Android. If you are developing on the JVM please add a dependency to firebase-client-jvm instead.

Using Gradle or Maven

We publish builds of our Java SDK to the Maven central repository. To install the library inside Android Studio, you can simply declare it as dependency in your build.gradle file:

dependencies {
    compile 'com.firebase:firebase-client-android:2.5.2+'

If you are getting a build error complaining about duplicate files you can choose to exclude those files by adding the packagingOptions directive to your build.gradle file:

android {
    packagingOptions {
        exclude 'META-INF/LICENSE'
        exclude 'META-INF/LICENSE-FIREBASE.txt'
        exclude 'META-INF/NOTICE'

If you use Maven to build your application, you can add the following dependency to your pom.xml:


Download and Install

You can grab the latest Firebase SDK for Android here:
Download Firebase Android SDK

After downloading the JAR, place it on your application's classpath. Typically, this is in your libs folder. Depending on your IDE, you may need to explicitly add the library to your project as a dependency.

Add Internet Permission

The Firebase library requires the android.permission.INTERNET permission to operate. Your app will not work unless you add this permission to your AndroidManifest.xml file:

<uses-permission android:name="android.permission.INTERNET" />

That's it! Now we're ready to start reading and writing data to the Firebase database, which we'll cover in the next parts of the guide.

Setup Firebase on Android

The Firebase library must be initialized once with an Android context. This must happen before any Firebase app reference is created or used. You can add the setup code to your Android Application's or Activity's onCreate method.

If your Android app has multiple activities, add this code to your Application Class. Otherwise add it in your main activity.

public void onCreate() {
    // other setup code
  1. 1


    Installation & Setup

  2. 2


    Understanding Data

  3. 3


    Saving Data

  4. 4


    Retrieving Data

  5. 5


    Structuring Data

  6. 6


    Understanding Security

  7. 7


    User Authentication

  8. 8


    Offline Capabilities