Firebase Android SDK
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.
.github/ISSUE_TEMPLATE Initial Open-source commit. Sep 5, 2018
.idea Initial Open-source commit. Sep 5, 2018
.opensource Initial Open-source commit. Sep 5, 2018
buildSrc Revert "Add maven proxy configuration. (#20)" (#51) Oct 2, 2018
ci Splitting into pre and post proguard tests (#36) Sep 25, 2018
firebase-common Version bumps (#57) Oct 3, 2018
firebase-database-collection Enabled linting for all remaining projects (#67) Oct 9, 2018
firebase-database Upgrade errorprone to latest version. (#70) Oct 11, 2018
firebase-firestore Better POJO Support for Document Fields Oct 23, 2018
firebase-functions Version bumps (#57) Oct 3, 2018
firebase-storage Enabled linting for all remaining projects (#67) Oct 9, 2018
gradle Initial Open-source commit. Sep 5, 2018
protolite-well-known-types Initial Open-source commit. Sep 5, 2018
test-apps Swapped order of dependencies for smoke tests (#86) Oct 23, 2018
third_party Initial Open-source commit. Sep 5, 2018
tools/errorprone Initial Open-source commit. Sep 5, 2018
.gitignore Adds Continuous Integration scripts to the repo. (#17) Sep 17, 2018 Initial Open-source commit. Sep 5, 2018
LICENSE Initial Open-source commit. Sep 5, 2018 Removed preguarding of the SDKs. (#44) Sep 27, 2018
default-preguard.txt Initial Open-source commit. Sep 5, 2018
gradlew Initial Open-source commit. Sep 5, 2018
gradlew.bat Initial Open-source commit. Sep 5, 2018
obfuscate_dict.txt Initial Open-source commit. Sep 5, 2018
root-project.gradle Upgrade errorprone to latest version. (#70) Oct 11, 2018
settings.gradle Initial Open-source commit. Sep 5, 2018
subprojects.cfg Initial Open-source commit. Sep 5, 2018

Firebase Android Open Source Development

This repository contains a subset of the Firebase Android SDK source. It currently includes the following Firebase libraries, and some of their dependencies:

  • firebase-common
  • firebase-database
  • firebase-functions
  • firebase-firestore
  • firebase-storage

Firebase is an app development platform with tools to help you build, grow and monetize your app. More information about Firebase can be found at

Table of contents

  1. Getting Started
  2. Testing
    1. Unit Testing
    2. Integration Testing
  3. Proguarding
    1. APIs used via reflection
    2. APIs intended for developer consumption
    3. APIs intended for other Firebase SDKs
  4. Publishing
    1. Dependencies
    2. Commands
  5. Code Formatting
  6. Contributing

Getting Started

  • Install the latest Android Studio (should be 3.0.1 or later)
  • Clone the repo (git clone
  • Import the firebase-android-sdk gradle project into Android Studio using the Import project(Gradle, Eclipse ADT, etc. option.


Firebase Android libraries exercise all three types of tests recommended by the Android Testing Pyramid. Depending on the requirements of the specific project, some or all of these tests may be used to support changes.

Unit Testing

These are tests that run on your machine's local Java Virtual Machine (JVM). At runtime, these tests are executed against a modified version of android.jar where all final modifiers have been stripped off. This lets us sandbox behaviors at desired places and use popular mocking libraries.

Unit tests can be executed on the command line by running

./gradlew :<firebase-project>:check

Integration Testing

These are tests that run on a hardware device or emulator. These tests have access to Instrumentation APIs, give you access to information such as the Android Context. In Firebase, instrumentation tests are used at different capacities by different projects. Some tests may exercise device capabilities, while stubbing any calls to the backend, while some others may call out to nightly backend builds to ensure distributed API compatibility.

Along with Espresso, they are also used to test projects that have UI components.

Project Setup

Before you can run integration tests, you need to add a google-services.json file to the root of your checkout. You can use the google-services.json from any project that includes an Android App, though you'll likely want one that's separate from any production data you have because our tests write random data.

If you don't have a suitable testing project already:

  • Open the Firebase console
  • If you don't yet have a project you want to use for testing, create one.
  • Add an Android app to the project
  • Give the app any package name you like.
  • Download the resulting google-services.json file and put it in the root of your checkout.

Running Integration Tests

Integration tests can be executed on the command line by running

./gradlew :<firebase-project>:connectedCheck


Firebase SDKs use some special annotations for tooling purposes.


APIs that need to be preserved up until the app's runtime can be annotated with @Keep. The @Keep annotation is blessed to be honored by android's default proguard configuration. A common use for this annotation is because of reflection. These APIs should be generally discouraged, because they can't be proguarded.


APIs that are intended to be used by Firebase SDKs should be annotated with @KeepForSdk. The key benefit here is that the annotation is blessed to throw linter errors on Android Studio if used by the developer from a non firebase package, thereby providing a valuable guard rail.


We annotate APIs that meant to be used by developers with @PublicAPI. This annotation will be used by tooling to help inform the version bump (major, minor, patch) that is required for the next release.


Firebase SDKs do not proguard themselves, but support proguarding. Firebase SDKs themselves are proguard friendly, but the dependencies of Firebase SDKs may not be.

Proguard config

In addition to preguard.txt, projects declare an additional set of proguard rules in a proguard.txt that are honored by the developer's app while building the app's proguarded apk. This file typically contains the keep rules that need to be honored during the app' s proguarding phase.

As a best practice, these explicit rules should be scoped to only libraries whose source code is outside the firebase-android-sdk codebase making annotation based approaches insufficient.The combination of keep rules resulting from the annotations, the preguard.txt and the proguard.txt collectively determine the APIs that are preserved at runtime.


Firebase is published as a collection of libraries each of which either represents a top level product, or contains shared functionality used by one or more projects. The projects are published as managed maven artifacts available at Google's Maven Repository. This section helps reason about how developers may make changes to firebase projects and have their apps depend on the modified versions of Firebase.


Any dependencies, within the projects, or outside of Firebase are encoded as maven dependencies into the pom file that accompanies the published artifact. This allows the developer's build system (typically Gradle) to build a dependency graph and select the dependencies using its own resolution strategy


The simplest way to publish a project and all its associated dependencies is to just publish all projects. The following command builds SNAPSHOT dependencies of all projects. All pom level dependencies within the published artifacts will also point to SNAPSHOT versions that are co-published.

./gradlew publishAllToLocal

Developers may take a dependency on these locally published versions by adding the mavenLocal() repository to your repositories block in your app module's build.gradle.

For more advanced use cases where developers wish to make changes to a project, but have transitive dependencies point to publicly released versions, individual projects may be published as follows.

# e.g. to publish Firestore and Functions
./gradlew -PprojectsToPublish=":firebase-firestore,:firebase-functions" \

Code Formatting

Code in this repo is formatted with the google-java-format tool. You can enable this formatting in Android Studio by downloading and installing the google-java-format plugin.

To run formatting on your entire project you can run

./gradlew :<firebase-project>:googleJavaFormat


We love contributions! Please read our contribution guidelines to get started.