blob: 52813a80441977819a2c14cd33f0f6b63919f5bf [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"
Yigit Boyar19d16da2022-04-15 14:50:33 -070043 sdkmanager --install "cmake;3.22.1" --channel=3 #channel 3 is the canary channel
Dustin Lam2fce3fd2021-11-17 12:16:03 -080044 ```
45
Rahul Ravikumar10efcea2020-07-16 15:52:37 -070046 Next, you need to set up the following environment variables:
47
48 ```bash
49 # You could also add this to your .{bash|zsh}rc file.
50 export JAVA_HOME="location of JDK 11 folder"
mzgreen42e3a6a2020-07-25 20:57:09 +053051 export ANDROID_SDK_ROOT="location of the Android SDK folder"
Dustin Lam2fce3fd2021-11-17 12:16:03 -080052 export ANDROID_NDK_ROOT="location of the Android NDK folder containing version 23.1.7779620"
Rahul Ravikumar10efcea2020-07-16 15:52:37 -070053 ```
54
55### Checkout & Importing a Project
56
57The list of folders that can be contributed to, using the GitHub repository are:
58
59```
60androidx
Simon Schillere1e83c62020-10-14 09:59:07 -070061 -- activity
Dustin Lam7c04f762020-12-11 17:36:12 -080062 -- biometric
Dustin Lamc93a99d2020-12-31 00:08:18 +000063 -- compose/compiler
jimgoog51f8af32021-08-11 17:45:19 +000064 -- compose/runtime
Dustin Lam4e42fb12021-07-30 17:04:03 -070065 -- datastore
Simon Schillere1e83c62020-10-14 09:59:07 -070066 -- fragment
Dustin Lam841bb082020-12-17 18:13:34 +000067 -- lifecycle
Simon Schillere1e83c62020-10-14 09:59:07 -070068 -- navigation
Dustin Lamd6009c32020-08-13 11:51:05 -070069 -- paging
Rahul Ravikumar10efcea2020-07-16 15:52:37 -070070 -- room
71 -- work
72```
73
Alan Viverette053e7e62020-12-15 10:22:06 -050074**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 -070075
Frieder Bluemle07c59542020-10-28 23:24:13 -070076Fork the [androidx/androidx](https://github.com/androidx/androidx) repository.
Rahul Ravikumar10efcea2020-07-16 15:52:37 -070077
Aurimas4b939852020-07-23 23:57:49 +000078We recommend cloning using blob filter to reduce checkout size:
79```bash
Dustin Lamf66d2aa2020-09-10 19:21:50 -070080git clone https://github.com/YOUR_USERNAME/androidx.git
Aurimas4b939852020-07-23 23:57:49 +000081```
82
Rahul Ravikumare6857b32020-10-15 22:13:38 +000083---
84
85> NOTE: If you are low on disk space, then you can use the following command to save some space in your checkout. :point_left:
86
87```bash
88# Filters any blob > 10M
89git clone --filter=blob:limit=10M https://github.com/YOUR_USERNAME/androidx.git
90```
91---
92
Rahul Ravikumar10efcea2020-07-16 15:52:37 -070093Let’s assume that you want to make a contribution to Room. The first step is to launch Android Studio and import the Room project.
94
95First launch Android Studio using:
96
97```bash
98cd androidx/room
99# This will automatically launch the `room` project in Android Studio.
100./gradlew studio
101```
102
103The studio task automatically downloads the correct version of Android Studio that matches the Android Gradle Plugin version.
104
105### Making Changes
106
107You 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.
108
109### Validating changes locally
110
111Before 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.
112
113Apart from this, there are checks that ensure developers follow the Android coding standards & guidelines.
114
115To make sure that your code passes all the above checks & tests you can run:
116
117```bash
118# Switch to the `room` directory or the project you are working on.
119cd room
120# Run device side and host side tests
121./gradlew test connectedCheck
122
123# Run additional checks
124./gradlew buildOnServer
125
126# If you are testing on an emulator, you can disable benchmark tests as
127# follows since they require a real device to run
128./gradlew \
129 test connectedCheck \
130 -x :room:room-benchmark:cC \
131 -x :room:integration-tests:room-incremental-annotation-processing:test
132```
133
134Once your changes look good, you can push them to your fork of the repository. Now you are ready to make a pull request.
135
136**Note:** When you make changes to an API, you need to run:
137
138```
139./gradlew updateApi
140```
141
Alan Viverette053e7e62020-12-15 10:22:06 -0500142If 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 -0700143
144This helps the AndroidX project keep track of API changes and avoid inadvertently adding APIs or introduce backwards incompatible changes.
145
Ahmed El-Helwa82b8132020-08-05 00:19:35 +0000146**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.
147
Rahul Ravikumar10efcea2020-07-16 15:52:37 -0700148**Note: CI build will already check for these but it is best to run them locally to speedup the process.**
149
150### Making a Pull Request
151
Frieder Bluemle07c59542020-10-28 23:24:13 -0700152To 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 -0700153
154Then click on the compare across forks and select your forked repository as the HEAD repository. Then click Create.
155
156All pull requests **must follow** the following conventions.
157
1581. The pull request includes a short description of the change, and a longer detailed description.
1592. Include a Test stanza in the pull request which describes the steps followed by the developer to test the changes.
1603. 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.
161
162Here is an example:
163
164```
165Short description for the change.
166
167Longer explanation for the change.
168
169Test: A test stanza. For e.g. /gradlew test connectedCheck
170Fixes: b/<bugId> if applicable
171```
172
173### The Pull Request Workflow
174
Alan Viverette053e7e62020-12-15 10:22:06 -0500175AndroidX 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 -0700176
177Here is what a typical pull request workflow looks like:
178
Alan Viverette053e7e62020-12-15 10:22:06 -05001791. Create a GitHub pull request from **your forked repository** to the androidx-main branch on GitHub.
Rahul Ravikumar10efcea2020-07-16 15:52:37 -07001802. Sign the Contributor’s License Agreement at https://cla.developers.google.com/ to get @googlebot to give you the `cla: yes` label.
1813. 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.
1824. Once the changes look good, a Googler will Approve your pull request on GitHub.
1835. Your PR will be **tested using GitHub workflows**. You can monitor these GitHub workflows by using the Actions tab in your forked repository.
1846. 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 -05001857. 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 -07001868. 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.
187
188### Running into problems?
189
190- 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).