|
| 1 | +# Jules Onboarding Guide for `firebase-android-sdk` |
| 2 | + |
| 3 | +This guide provides essential information for working within the `firebase-android-sdk` repository. |
| 4 | + |
| 5 | +## Table of Contents |
| 6 | +- [Environment Setup](#environment-setup) |
| 7 | +- [Testing](#testing) |
| 8 | +- [API Surface](#api-surface) |
| 9 | +- [Best Practices](#best-practices) |
| 10 | +- [Common Patterns](#common-patterns) |
| 11 | +- [External Dependencies](#external-dependencies) |
| 12 | +- [Updating this Guide](#updating-this-guide) |
| 13 | + |
| 14 | +--- |
| 15 | + |
| 16 | +## Environment Setup |
| 17 | + |
| 18 | +To work with this repository, the Android SDK must be installed. Use the `sdkmanager` command-line tool for this purpose. |
| 19 | + |
| 20 | +1. **Install Android SDK Command-Line Tools**: |
| 21 | + - If not already installed, download the command-line tools from the [Android Studio page](https://developer.android.com/studio#command-line-tools-only). |
| 22 | + - Create a directory for the Android SDK, e.g., `android_sdk`. |
| 23 | + - Unzip the downloaded package and move the `cmdline-tools` directory into the `android_sdk` directory. |
| 24 | + - The final structure should be `android_sdk/cmdline-tools/`. |
| 25 | + |
| 26 | +2. **Install required SDK packages**: |
| 27 | + - Use `sdkmanager` to install the necessary platforms, build tools, and other packages. For example: |
| 28 | + ```bash |
| 29 | + # List all available packages |
| 30 | + sdkmanager --list |
| 31 | + |
| 32 | + # Install platform tools and the SDK for API level 33 |
| 33 | + sdkmanager "platform-tools" "platforms;android-33" |
| 34 | + |
| 35 | + # Accept all licenses |
| 36 | + sdkmanager --licenses |
| 37 | + ``` |
| 38 | + - Refer to the specific requirements of the project to determine which packages to install. |
| 39 | + |
| 40 | +3. **Configure for integration tests**: |
| 41 | + - To run integration tests, a `google-services.json` file is required. |
| 42 | + - Place this file in the root of the repository. |
| 43 | + |
| 44 | +--- |
| 45 | + |
| 46 | +## Testing |
| 47 | + |
| 48 | +This repository uses two main types of tests: |
| 49 | + |
| 50 | +1. **Unit Tests**: |
| 51 | + - These tests run on the local JVM. |
| 52 | + - To execute unit tests for a specific project, run: |
| 53 | + ```bash |
| 54 | + ./gradlew :<firebase-project>:check |
| 55 | + ``` |
| 56 | + |
| 57 | +2. **Integration Tests**: |
| 58 | + - These tests run on a hardware device or emulator. |
| 59 | + - Ensure a `google-services.json` file is present in the repository root. |
| 60 | + - To execute integration tests for a specific project, run: |
| 61 | + ```bash |
| 62 | + ./gradlew :<firebase-project>:connectedCheck |
| 63 | + ``` |
| 64 | + |
| 65 | +--- |
| 66 | + |
| 67 | +## API Surface |
| 68 | + |
| 69 | +The public API of the Firebase SDKs is managed using a set of annotations: |
| 70 | + |
| 71 | +- `@PublicApi`: Marks APIs that are intended for public consumption by developers. |
| 72 | +- `@KeepForSdk`: Marks APIs that are intended for use by other Firebase SDKs. These APIs will trigger a linter error if used by developers outside of a Firebase package. |
| 73 | +- `@Keep`: Marks APIs that need to be preserved at runtime, usually due to reflection. This annotation should be used sparingly as it prevents the code from being proguarded. |
| 74 | + |
| 75 | +--- |
| 76 | + |
| 77 | +## Best Practices |
| 78 | + |
| 79 | +- **Code Formatting**: The repository uses `spotless` for code formatting. To format the code in a specific project, run: |
| 80 | + ```bash |
| 81 | + ./gradlew :<firebase-project>:spotlessApply |
| 82 | + ``` |
| 83 | +- **Dependency Management**: Dependencies are managed using Gradle. Be mindful of the impact of new dependencies on the size of the SDKs. |
| 84 | + |
| 85 | +--- |
| 86 | + |
| 87 | +## Common Patterns |
| 88 | + |
| 89 | +This repository uses a combination of dependency injection frameworks: |
| 90 | + |
| 91 | +- **`firebase-components`**: This is a custom dependency injection framework used for discovery and dependency injection between different Firebase SDKs. It allows SDKs to register their components and declare dependencies on other components. The initialization is managed by `FirebaseApp`. |
| 92 | + |
| 93 | +- **Dagger**: Dagger is used for internal dependency injection within individual SDKs. This helps to create more testable and maintainable code. Dagger components are typically instantiated within the `ComponentRegistrar` of an SDK, which allows for the injection of dependencies from `firebase-components` into the Dagger graph. |
| 94 | + |
| 95 | +--- |
| 96 | + |
| 97 | +## External Dependencies |
| 98 | + |
| 99 | +Do not add new external dependencies to the project unless explicitly asked to do so. The Firebase SDKs are designed to be lightweight, and adding new dependencies can increase the size of the final artifacts. |
| 100 | + |
| 101 | +--- |
| 102 | + |
| 103 | +## Updating this Guide |
| 104 | + |
| 105 | +If new patterns or conventions are discovered, update this guide to ensure it remains a useful resource. |
0 commit comments