11# Firebase Android Open Source Development
22
3- This repository contains the source code for all Android Firebase SDKs except
4- Analytics and Auth.
3+ This repository contains the source code for all Android Firebase SDKs except Analytics and Auth.
54
6- Firebase is an app development platform with tools to help you build, grow and
7- monetize your app. More information about Firebase can be found at
8- https://firebase.google.com .
5+ Firebase is an app development platform with tools to help you build, grow and monetize your app.
6+ More information about Firebase can be found at https://firebase.google.com .
97
108## Table of contents
119
@@ -15,10 +13,8 @@ https://firebase.google.com.
1513 1 . [ Integration Testing] ( #integration-testing )
16141 . [ Proguarding] ( #proguarding )
1715 1 . [ APIs used via reflection] ( #APIs-used-via-reflection )
18- 1 . [ APIs intended for developer
19- consumption] ( #APIs-intended-for-developer-consumption )
20- 1 . [ APIs intended for other Firebase
21- SDKs] ( #APIs-intended-for-other-firebase-sdks )
16+ 1 . [ APIs intended for developer consumption] ( #APIs-intended-for-developer-consumption )
17+ 1 . [ APIs intended for other Firebase SDKs] ( #APIs-intended-for-other-firebase-sdks )
22181 . [ Publishing] ( #publishing )
2319 1 . [ Dependencies] ( #dependencies )
2420 1 . [ Commands] ( #commands )
@@ -27,23 +23,22 @@ https://firebase.google.com.
2723
2824## Getting Started
2925
30- * Install the latest Android Studio (should be Meerkat | 2024.3.1 or later)
31- * Clone the repo (
` git clone --recurse-submodules [email protected] :firebase/firebase-android-sdk.git ` )
32- * When cloning the repo, it is important to get the submodules as well. If
33- you have already cloned the repo without the submodules, you can update the
34- submodules by running ` git submodule update --init --recursive ` .
35- * Import the firebase-android-sdk gradle project into Android Studio using the
36- ** Import project(Gradle, Eclipse ADT, etc.)** option.
37- * ` firebase-crashlytics-ndk ` must be built with NDK 21. See
38- [ firebase-crashlytics-ndk] ( firebase-crashlytics-ndk/README.md ) for more
39- details.
26+ - Install the latest Android Studio (should be Meerkat | 2024.3.1 or later)
27+ - Clone the repo (
` git clone --recurse-submodules [email protected] :firebase/firebase-android-sdk.git ` )
28+ - When cloning the repo, it is important to get the submodules as well. If you have already cloned
29+ the repo without the submodules, you can update the submodules by running
30+ ` git submodule update --init --recursive ` .
31+ - Import the firebase-android-sdk gradle project into Android Studio using the ** Import
32+ project(Gradle, Eclipse ADT, etc.)** option.
33+ - ` firebase-crashlytics-ndk ` must be built with NDK 21. See
34+ [ firebase-crashlytics-ndk] ( firebase-crashlytics-ndk/README.md ) for more details.
4035
4136## Testing
4237
4338Firebase Android libraries exercise all three types of tests recommended by the
4439[ Android Testing Pyramid] ( https://developer.android.com/training/testing/fundamentals#testing-pyramid ) .
45- Depending on the requirements of the specific project, some or all of these
46- tests may be used to support changes.
40+ Depending on the requirements of the specific project, some or all of these tests may be used to
41+ support changes.
4742
4843> :warning : ** Running tests with errorprone**
4944>
@@ -53,48 +48,46 @@ tests may be used to support changes.
5348
5449### Unit Testing
5550
56- These are tests that run on your machine's local Java Virtual Machine (JVM). At
57- runtime, these tests are executed against a modified version of android.jar
58- where all final modifiers have been stripped off. This lets us sandbox behaviors
59- at desired places and use popular mocking libraries.
51+ These are tests that run on your machine's local Java Virtual Machine (JVM). At runtime, these tests
52+ are executed against a modified version of android.jar where all final modifiers have been stripped
53+ off. This lets us sandbox behaviors at desired places and use popular mocking libraries.
6054
6155Unit tests can be executed on the command line by running
56+
6257``` bash
6358./gradlew :< firebase-project> :check
6459```
6560
6661### Integration Testing
6762
68- These are tests that run on a hardware device or emulator. These tests have
69- access to Instrumentation APIs, give you access to information such as the
70- [ Android Context] ( https://developer.android.com/reference/android/content/Context ) .
71- In Firebase, instrumentation tests are used at different capacities by different
72- projects. Some tests may exercise device capabilities, while stubbing any calls
73- to the backend, while some others may call out to nightly backend builds to
74- ensure distributed API compatibility.
63+ These are tests that run on a hardware device or emulator. These tests have access to
64+ Instrumentation APIs, give you access to information such as the
65+ [ Android Context] ( https://developer.android.com/reference/android/content/Context ) . In Firebase,
66+ instrumentation tests are used at different capacities by different projects. Some tests may
67+ exercise device capabilities, while stubbing any calls to the backend, while some others may call
68+ out to nightly backend builds to ensure distributed API compatibility.
7569
76- Along with Espresso, they are also used to test projects that have UI
77- components.
70+ Along with Espresso, they are also used to test projects that have UI components.
7871
7972#### Project Setup
8073
81- Before you can run integration tests, you need to add a ` google-services.json `
82- file to the root of your checkout. You can use the ` google-services.json ` from
83- any project that includes an Android App, though you'll likely want one that's
84- separate from any production data you have because our tests write random data.
74+ Before you can run integration tests, you need to add a ` google-services.json ` file to the root of
75+ your checkout. You can use the ` google-services.json ` from any project that includes an Android App,
76+ though you'll likely want one that's separate from any production data you have because our tests
77+ write random data.
8578
8679If you don't have a suitable testing project already:
8780
88- * Open the [ Firebase console] ( https://console.firebase.google.com/ )
89- * If you don't yet have a project you want to use for testing, create one.
90- * Add an Android app to the project
91- * Give the app any package name you like.
92- * Download the resulting ` google-services.json ` file and put it in the root of
93- your checkout.
81+ - Open the [ Firebase console] ( https://console.firebase.google.com/ )
82+ - If you don't yet have a project you want to use for testing, create one.
83+ - Add an Android app to the project
84+ - Give the app any package name you like.
85+ - Download the resulting ` google-services.json ` file and put it in the root of your checkout.
9486
9587#### Running Integration Tests on Local Emulator
9688
9789Integration tests can be executed on the command line by running
90+
9891``` bash
9992./gradlew :< firebase-project> :connectedCheck
10093```
@@ -103,11 +96,12 @@ Integration tests can be executed on the command line by running
10396
10497> You need additional setup for this to work:
10598>
106- > * ` gcloud ` needs to be [ installed] ( https://cloud.google.com/sdk/install ) on local machine
107- > * ` gcloud ` needs to be configured with a project that has billing enabled
108- > * ` gcloud ` needs to be authenticated with credentials that have 'Firebase Test Lab Admin' role
99+ > - ` gcloud ` needs to be [ installed] ( https://cloud.google.com/sdk/install ) on local machine
100+ > - ` gcloud ` needs to be configured with a project that has billing enabled
101+ > - ` gcloud ` needs to be authenticated with credentials that have 'Firebase Test Lab Admin' role
109102
110103Integration tests can be executed on the command line by running
104+
111105``` bash
112106./gradlew :< firebase-project> :deviceCheck
113107```
@@ -134,92 +128,84 @@ Firebase SDKs use some special annotations for tooling purposes.
134128### @Keep
135129
136130APIs that need to be preserved up until the app's runtime can be annotated with
137- [ @Keep ] ( https://developer.android.com/reference/android/support/annotation/Keep ) .
138- The
139- [ @Keep ] ( https://developer.android.com/reference/android/support/annotation/Keep )
140- annotation is * blessed* to be honored by android's [ default proguard
141- configuration] ( https://developer.android.com/studio/write/annotations#keep ) . A common use for
142- this annotation is because of reflection. These APIs should be generally ** discouraged** , because
143- they can't be proguarded.
131+ [ @Keep ] ( https://developer.android.com/reference/android/support/annotation/Keep ) . The
132+ [ @Keep ] ( https://developer.android.com/reference/android/support/annotation/Keep ) annotation is
133+ _ blessed_ to be honored by android's
134+ [ default proguard configuration] ( https://developer.android.com/studio/write/annotations#keep ) . A
135+ common use for this annotation is because of reflection. These APIs should be generally
136+ ** discouraged** , because they can't be proguarded.
144137
145138### @KeepForSdk
146139
147- APIs that are intended to be used by Firebase SDKs should be annotated with
148- ` @KeepForSdk ` . The key benefit here is that the annotation is * blessed* to throw
149- linter errors on Android Studio if used by the developer from a non firebase
150- package, thereby providing a valuable guard rail.
151-
140+ APIs that are intended to be used by Firebase SDKs should be annotated with ` @KeepForSdk ` . The key
141+ benefit here is that the annotation is _ blessed_ to throw linter errors on Android Studio if used by
142+ the developer from a non firebase package, thereby providing a valuable guard rail.
152143
153144### @PublicApi
154145
155146We annotate APIs that meant to be used by developers with
156- [ @PublicAPI ] ( firebase-common/src/main/java/com/google/firebase/annotations/PublicApi.java ) . This
147+ [ @PublicAPI ] ( firebase-common/src/main/java/com/google/firebase/annotations/PublicApi.java ) . This
157148annotation will be used by tooling to help inform the version bump (major, minor, patch) that is
158149required for the next release.
159150
160151## Proguarding
161152
162- Firebase SDKs do not proguard themselves, but support proguarding. Firebase SDKs themselves are
153+ Firebase SDKs do not proguard themselves, but support proguarding. Firebase SDKs themselves are
163154proguard friendly, but the dependencies of Firebase SDKs may not be.
164155
165156### Proguard config
166157
167- In addition to preguard.txt, projects declare an additional set of proguard
168- rules in a proguard.txt that are honored by the developer's app while building
169- the app's proguarded apk. This file typically contains the keep rules that need
170- to be honored during the app' s proguarding phase.
158+ In addition to preguard.txt, projects declare an additional set of proguard rules in a proguard.txt
159+ that are honored by the developer's app while building the app's proguarded apk. This file typically
160+ contains the keep rules that need to be honored during the app' s proguarding phase.
171161
172- As a best practice, these explicit rules should be scoped to only libraries
173- whose source code is outside the firebase-android-sdk codebase making annotation
174- based approaches insufficient.The combination of keep rules resulting from the
175- annotations, the preguard.txt and the proguard.txt collectively determine the
176- APIs that are preserved at ** runtime** .
162+ As a best practice, these explicit rules should be scoped to only libraries whose source code is
163+ outside the firebase-android-sdk codebase making annotation based approaches insufficient.The
164+ combination of keep rules resulting from the annotations, the preguard.txt and the proguard.txt
165+ collectively determine the APIs that are preserved at ** runtime** .
177166
178167## Publishing
179168
180- Firebase is published as a collection of libraries each of which either
181- represents a top level product, or contains shared functionality used by one or
182- more projects. The projects are published as managed maven artifacts available
183- at [ Google's Maven Repository] ( https://maven.google.com ) . This section helps
184- reason about how developers may make changes to firebase projects and have their
185- apps depend on the modified versions of Firebase.
169+ Firebase is published as a collection of libraries each of which either represents a top level
170+ product, or contains shared functionality used by one or more projects. The projects are published
171+ as managed maven artifacts available at [ Google's Maven Repository] ( https://maven.google.com ) . This
172+ section helps reason about how developers may make changes to firebase projects and have their apps
173+ depend on the modified versions of Firebase.
186174
187175### Dependencies
188176
189177Any dependencies, within the projects, or outside of Firebase are encoded as
190178[ maven dependencies] ( https://maven.apache.org/guides/introduction/introduction-to-dependency-mechanism.html )
191- into the ` pom ` file that accompanies the published artifact. This allows the
192- developer's build system (typically Gradle) to build a dependency graph and
193- select the dependencies using its own [ resolution
194- strategy] ( https://docs.gradle.org/current/dsl/org.gradle.api.artifacts.ResolutionStrategy.html )
179+ into the ` pom ` file that accompanies the published artifact. This allows the developer's build
180+ system (typically Gradle) to build a dependency graph and select the dependencies using its own
181+ [ resolution strategy] ( https://docs.gradle.org/current/dsl/org.gradle.api.artifacts.ResolutionStrategy.html )
195182
196183### Commands
197184
198- For more advanced use cases where developers wish to make changes to a project,
199- but have transitive dependencies point to publicly released versions, individual
200- projects may be published as follows.
185+ For more advanced use cases where developers wish to make changes to a project, but have transitive
186+ dependencies point to publicly released versions, individual projects may be published as follows.
201187
202188``` bash
203189# e.g. to publish Firestore and Functions
204190./gradlew -PprojectsToPublish=" firebase-firestore,firebase-functions" \
205191 publishReleasingLibrariesToMavenLocal
206192```
207193
208- Developers may take a dependency on these locally published versions by adding
209- the ` mavenLocal() ` repository to your [ repositories
210- block] ( https://docs.gradle.org/current/userguide/declaring_repositories.html ) in
211- your app module's build.gradle.
194+ Developers may take a dependency on these locally published versions by adding the ` mavenLocal() `
195+ repository to your
196+ [ repositories block] ( https://docs.gradle.org/current/userguide/declaring_repositories.html ) in your
197+ app module's build.gradle.
212198
213199### Code Formatting
214200
215201Java and Kotlin are both formatted using ` spotless ` .
216202
217203To run formatting on a project, run
204+
218205``` bash
219206./gradlew :< firebase-project> :spotlessApply
220207```
221208
222209### Contributing
223210
224- We love contributions! Please read our
225- [ contribution guidelines] ( /CONTRIBUTING.md ) to get started.
211+ We love contributions! Please read our [ contribution guidelines] ( /CONTRIBUTING.md ) to get started.
0 commit comments