blob: 54cff69da078876d57fd71fcdf7d1c0a76cd90b2 [file] [log] [blame] [view]
Rahul Ravikumar10efcea2020-07-16 15:52:37 -07001## Introduction
2
3This repo is an official mirror of Android Jetpack libraries that enables external contributions to a select number of libraries via GitHub pull requests.
4
5### Why this repository exists
6
7The Android team has been exploring how we could make it easier to develop libraries that don’t rely on infrastructure from the Android Open Source Project (AOSP). This GitHub infrastructure has two benefits. First, it makes it easier to contribute to a small set of Jetpack libraries. Second, this parallel infrastructure makes it possible to build and test Jetpack libraries against non-Android target platforms.
8
9### What can you contribute to?
10
Dustin Lamd6009c32020-08-13 11:51:05 -070011You can start contributing to any of the following library groups from GitHub:
Dustin Lameec21a42020-10-13 15:12:26 -070012 - [Activity](https://developer.android.com/guide/components/activities/intro-activities)
Dustin Lam7c04f762020-12-11 17:36:12 -080013 - [Biometric](https://developer.android.com/training/sign-in/biometric-auth)
Yigit Boyar2abb89a2022-02-14 17:15:40 -080014 - [Collection](https://developer.android.com/jetpack/androidx/releases/collection)
Dustin Lamc93a99d2020-12-31 00:08:18 +000015 - [Compose Compiler](https://developer.android.com/jetpack/androidx/releases/compose-compiler)
jimgoog51f8af32021-08-11 17:45:19 +000016 - [Compose Runtime](https://developer.android.com/jetpack/androidx/releases/compose-runtime)
Dustin Lam4e42fb12021-07-30 17:04:03 -070017 - [DataStore](https://developer.android.com/topic/libraries/architecture/datastore)
Dustin Lameec21a42020-10-13 15:12:26 -070018 - [Fragment](https://developer.android.com/guide/components/fragments)
Dustin Lam841bb082020-12-17 18:13:34 +000019 - [Lifecycle](https://developer.android.com/topic/libraries/architecture/lifecycle)
Dustin Lameec21a42020-10-13 15:12:26 -070020 - [Navigation](https://developer.android.com/guide/navigation)
Dustin Lamd6009c32020-08-13 11:51:05 -070021 - [Paging](https://developer.android.com/topic/libraries/architecture/paging)
22 - [Room](https://developer.android.com/topic/libraries/architecture/room)
23 - [WorkManager](https://developer.android.com/topic/libraries/architecture/workmanager)
Rahul Ravikumar10efcea2020-07-16 15:52:37 -070024
Rahul Ravikumar8f1880f2020-08-25 11:39:24 -070025Not sure where to start? Take a look at the official [feature/bug bounty list](http://goo.gle/androidx-bug-bounty).
26
Rahul Ravikumar10efcea2020-07-16 15:52:37 -070027Our tooling currently supports **macOS and Linux**. This new setup is a **work-in-progress**, so it might have some rough edges. Please bear with us while we streamline this workflow.
28
29## Getting Started
30
Frieder Bluemle07c59542020-10-28 23:24:13 -070031We have tried to make contributing to androidx a lot easier with this new setup. Just start by creating a fork of the [androidx/androidx](https://github.com/androidx/androidx) GitHub repository.
Rahul Ravikumar10efcea2020-07-16 15:52:37 -070032
33### One Time Setup
34
35- Click on the `Actions` tab in the forked `androidx` repository, and enable the use of `Workflows`.
36
37- Download and install JDK 11, if you don’t have it already.
38
Dustin Lam2fce3fd2021-11-17 12:16:03 -080039- Download and install the NDK
40
41 ```bash
42 sdkmanager --install "ndk;23.1.7779620"
43 ```
44
Rahul Ravikumar10efcea2020-07-16 15:52:37 -070045 Next, you need to set up the following environment variables:
46
47 ```bash
48 # You could also add this to your .{bash|zsh}rc file.
49 export JAVA_HOME="location of JDK 11 folder"
mzgreen42e3a6a2020-07-25 20:57:09 +053050 export ANDROID_SDK_ROOT="location of the Android SDK folder"
Dustin Lam2fce3fd2021-11-17 12:16:03 -080051 export ANDROID_NDK_ROOT="location of the Android NDK folder containing version 23.1.7779620"
Rahul Ravikumar10efcea2020-07-16 15:52:37 -070052 ```
53
54### Checkout & Importing a Project
55
56The list of folders that can be contributed to, using the GitHub repository are:
57
58```
59androidx
Simon Schillere1e83c62020-10-14 09:59:07 -070060 -- activity
Dustin Lam7c04f762020-12-11 17:36:12 -080061 -- biometric
Dustin Lamc93a99d2020-12-31 00:08:18 +000062 -- compose/compiler
jimgoog51f8af32021-08-11 17:45:19 +000063 -- compose/runtime
Dustin Lam4e42fb12021-07-30 17:04:03 -070064 -- datastore
Simon Schillere1e83c62020-10-14 09:59:07 -070065 -- fragment
Dustin Lam841bb082020-12-17 18:13:34 +000066 -- lifecycle
Simon Schillere1e83c62020-10-14 09:59:07 -070067 -- navigation
Dustin Lamd6009c32020-08-13 11:51:05 -070068 -- paging
Rahul Ravikumar10efcea2020-07-16 15:52:37 -070069 -- room
70 -- work
71```
72
Alan Viverette053e7e62020-12-15 10:22:06 -050073**Note:** For other projects, you will still need to use the Gerrit workflow used by the Android Open Source Project (AOSP). For more information, please look at the [README](https://cs.android.com/androidx/platform/frameworks/support/+/androidx-main:README.md).
Rahul Ravikumar10efcea2020-07-16 15:52:37 -070074
Frieder Bluemle07c59542020-10-28 23:24:13 -070075Fork the [androidx/androidx](https://github.com/androidx/androidx) repository.
Rahul Ravikumar10efcea2020-07-16 15:52:37 -070076
Aurimas4b939852020-07-23 23:57:49 +000077We recommend cloning using blob filter to reduce checkout size:
78```bash
Dustin Lamf66d2aa2020-09-10 19:21:50 -070079git clone https://github.com/YOUR_USERNAME/androidx.git
Aurimas4b939852020-07-23 23:57:49 +000080```
81
Rahul Ravikumare6857b32020-10-15 22:13:38 +000082---
83
84> NOTE: If you are low on disk space, then you can use the following command to save some space in your checkout. :point_left:
85
86```bash
87# Filters any blob > 10M
88git clone --filter=blob:limit=10M https://github.com/YOUR_USERNAME/androidx.git
89```
90---
91
Rahul Ravikumar10efcea2020-07-16 15:52:37 -070092Let’s assume that you want to make a contribution to Room. The first step is to launch Android Studio and import the Room project.
93
94First launch Android Studio using:
95
96```bash
97cd androidx/room
98# This will automatically launch the `room` project in Android Studio.
99./gradlew studio
100```
101
102The studio task automatically downloads the correct version of Android Studio that matches the Android Gradle Plugin version.
103
104### Making Changes
105
106You can now start making changes to the Room project. Making changes is just like making changes to any other Android project. It’s a good idea to build consensus on the change you intend to make. Make sure there is a related issue on the [AOSP issue tracker](https://issuetracker.google.com/issues/new?component=192731&template=842428) and start a conversation on that issue to ensure project maintainers are aware of it. It is best to start the conversation as early as possible to avoid duplicating work as other contributors might already be working on it.
107
108### Validating changes locally
109
110Before you send out a pull request, it’s always a good idea to run tests locally to make sure that you have not accidentally introduced bugs. Also, given all AndroidX projects follow semantic versioning, it's also important for projects to not introduce breaking changes without changing the library’s major version.
111
112Apart from this, there are checks that ensure developers follow the Android coding standards & guidelines.
113
114To make sure that your code passes all the above checks & tests you can run:
115
116```bash
117# Switch to the `room` directory or the project you are working on.
118cd room
119# Run device side and host side tests
120./gradlew test connectedCheck
121
122# Run additional checks
123./gradlew buildOnServer
124
125# If you are testing on an emulator, you can disable benchmark tests as
126# follows since they require a real device to run
127./gradlew \
128 test connectedCheck \
129 -x :room:room-benchmark:cC \
130 -x :room:integration-tests:room-incremental-annotation-processing:test
131```
132
133Once your changes look good, you can push them to your fork of the repository. Now you are ready to make a pull request.
134
135**Note:** When you make changes to an API, you need to run:
136
137```
138./gradlew updateApi
139```
140
Alan Viverette053e7e62020-12-15 10:22:06 -0500141If you are adding new APIs, then you might **additionally need to update** [LibraryVersions.kt](https://github.com/androidx/androidx/blob/androidx-main/buildSrc/src/main/kotlin/androidx/build/LibraryVersions.kt) as well, before running the updateApi task. This is **relevant when the library’s API is frozen** (betas, rc’s and stable versions). For alpha versions, you don’t have to update this file.
Rahul Ravikumar10efcea2020-07-16 15:52:37 -0700142
143This helps the AndroidX project keep track of API changes and avoid inadvertently adding APIs or introduce backwards incompatible changes.
144
Ahmed El-Helwa82b8132020-08-05 00:19:35 +0000145**Note:** In case you make a valid violation of Lint, you can use `@Suppress("Rule")` in Kotlin, or `@SuppressLint("Rule")` in Java to suppress the rule.
146
Rahul Ravikumar10efcea2020-07-16 15:52:37 -0700147**Note: CI build will already check for these but it is best to run them locally to speedup the process.**
148
149### Making a Pull Request
150
Frieder Bluemle07c59542020-10-28 23:24:13 -0700151To create a pull request click on [this](https://github.com/androidx/androidx/pulls) link and then click on New Pull Request.
Rahul Ravikumar10efcea2020-07-16 15:52:37 -0700152
153Then click on the compare across forks and select your forked repository as the HEAD repository. Then click Create.
154
155All pull requests **must follow** the following conventions.
156
1571. The pull request includes a short description of the change, and a longer detailed description.
1582. Include a Test stanza in the pull request which describes the steps followed by the developer to test the changes.
1593. Include a Fixes stanza that describes the issue being fixed. That way the corresponding issue trackers can automatically be resolved once the change lands in AOSP.
160
161Here is an example:
162
163```
164Short description for the change.
165
166Longer explanation for the change.
167
168Test: A test stanza. For e.g. /gradlew test connectedCheck
169Fixes: b/<bugId> if applicable
170```
171
172### The Pull Request Workflow
173
Alan Viverette053e7e62020-12-15 10:22:06 -0500174AndroidX is primarily developed in [AOSP](https://android.googlesource.com/platform/frameworks/support/+/androidx-main). This flow simply mirrors pull requests from GitHub into Gerrit, For all intents and purposes, AOSP is the **single** **source of truth**, all changes will be merged in Gerrit and mirrored back to GitHub.
Rahul Ravikumar10efcea2020-07-16 15:52:37 -0700175
176Here is what a typical pull request workflow looks like:
177
Alan Viverette053e7e62020-12-15 10:22:06 -05001781. Create a GitHub pull request from **your forked repository** to the androidx-main branch on GitHub.
Rahul Ravikumar10efcea2020-07-16 15:52:37 -07001792. Sign the Contributor’s License Agreement at https://cla.developers.google.com/ to get @googlebot to give you the `cla: yes` label.
1803. Your PR will be reviewed using the GitHub pull request flow. You can address the comments / suggestions in your forked repository and update the pull request as normal.
1814. Once the changes look good, a Googler will Approve your pull request on GitHub.
1825. Your PR will be **tested using GitHub workflows**. You can monitor these GitHub workflows by using the Actions tab in your forked repository.
1836. Once your **pull request has been approved** by a Googler, it will also be **mirrored to AOSP Gerrit**. You can find the link to Gerrit under the status check, `import/copybara` left by `@copybara-service`, by clicking details.
Alan Viverette053e7e62020-12-15 10:22:06 -05001847. Once **all** the checks in **Gerrit and GitHub** pass, your change will get merged in androidx-main in AOSP and mirrored back to androidx-main in GitHub. Congratulations, your change landed in AOSP!
Rahul Ravikumar10efcea2020-07-16 15:52:37 -07001858. Currently, your pull request will not get automatically closed when your changes are merged. So you will have to close the pull request manually. We are working on improving the workflow to address this.
186
187### Running into problems?
188
189- If you see GitHub workflows failing, then look at the verbose logs under the `Actions` tab for more information. If you don’t understand why a test might be failing, then reach out to us by creating a new issue [here](https://issuetracker.google.com/issues/new?component=923725&template=1480355).