Welcome to the world of Firebase Android development! Firebase is an extraordinary app development platform that provides a treasure trove of tools to build, grow, and monetize your app. This guide walks you through the essential steps to get started with Android Firebase SDKs while giving you insights into testing, proguarding, and publishing. Let’s jump in!
Table of Contents
Getting Started
- Install the latest version of Android Studio> (3.0.1 or later).
- Clone the repo using the command:
git clone --recurse-submodules git@github.com:firebase/firebase-android-sdk.git
- If you missed submodules during the clone, update them by running:
git submodule update --init --recursive
- Import the project into Android Studio by selecting the Import project (Gradle, Eclipse ADT, etc.) option.
- Ensure that firebase-crashlytics-ndk is built with NDK 21. Check out the firebase-crashlytics-ndk for more details.
Testing
The Firebase Android libraries incorporate all three types of tests recommended by the Android Testing Pyramid. Based on your project specifications, you may need to leverage one or more of these tests.
Unit Testing
Unit tests are your local superheroes! They operate within the confines of your Java Virtual Machine (JVM). When executed, they use a modified version of the android.jar to allow for behaviors to be sandboxed precisely where needed. You can engage the unit tests using:
bash.gradlew :firebase-project:check
Integration Testing
Integration tests are like the friends you call to help you move! These tests run on actual hardware devices or emulators, using the Instrumentation APIs to gather the necessary context from Android. Different Firebase projects may use these tests in varying capacities.
Before orchestrating these tests, prepare a google-services.json file by:
- Opening the Firebase console.
- Creating a new project that you will use for testing.
- Adding an Android app to the project and downloading the resulting google-services.json file.
- Placing this file into the root of your repository.
Proguarding
In the realm of Firebase SDKs, Proguarding is akin to a protective cloak that shields your project while enabling it to flourish. While the Firebase SDKs themselves do not proguard, they are designed to be proguard-friendly. Utilize proguard rules diligently in your proguard.txt file to avoid accidental exposure during the build process.
Publishing
Firebase is distributed as a collection of libraries. These libraries can either represent top-level products or encompass shared functionalities useful across various projects.
Dependencies
Dependencies are captured using maven dependencies within the project’s pom file. This facilitates a robust dependency graph creation, allowing Gradle’s resolution strategy to kick in efficiently.
Commands
Developers can publish modified versions of the Firebase projects locally. Use the command below to publish Firestore and Functions:
bash.gradlew -PprojectsToPublish=firebase-firestore,firebase-functions publishReleasingLibrariesToMavenLocal
To access locally published versions, make sure to include mavenLocal() in your repository block in your app module’s build.gradle.
Code Formatting
Maintain code clarity by implementing formatting standards. Both Java and Kotlin projects can utilize the Spotless Gradle plugin. Format your project by executing:
bash.gradlew :firebase-project:spotlessApply
Contributing
Your contributions matter! We wholeheartedly welcome your involvement. Please review the contribution guidelines to get started.
Troubleshooting Ideas
If you encounter issues during setup, here are a few troubleshooting tips:
- Ensure Android Studio is updated to the correct version.
- Verify that you have cloned the repo with submodules.
- Check that the google-services.json file is correctly placed in the root directory.
- If tests are not running, confirm your device or emulator has been configured properly.
For more insights, updates, or to collaborate on AI development projects, stay connected with fxis.ai.
At fxis.ai, we believe that such advancements are crucial for the future of AI, as they enable more comprehensive and effective solutions. Our team is continually exploring new methodologies to push the envelope in artificial intelligence, ensuring that our clients benefit from the latest technological innovations.