blob: 939fab82f46aac30342539d0000bd8fb7464c6e0 [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)
Alan Viverette63ba82e2022-04-25 11:24:03 -040013 - [AppCompat](https://developer.android.com/jetpack/androidx/releases/appcompat)
Dustin Lam7c04f762020-12-11 17:36:12 -080014 - [Biometric](https://developer.android.com/training/sign-in/biometric-auth)
Yigit Boyar2abb89a2022-02-14 17:15:40 -080015 - [Collection](https://developer.android.com/jetpack/androidx/releases/collection)
Dustin Lamc93a99d2020-12-31 00:08:18 +000016 - [Compose Compiler](https://developer.android.com/jetpack/androidx/releases/compose-compiler)
jimgoog51f8af32021-08-11 17:45:19 +000017 - [Compose Runtime](https://developer.android.com/jetpack/androidx/releases/compose-runtime)
Alan Viverette63ba82e2022-04-25 11:24:03 -040018 - [Core](https://developer.android.com/jetpack/androidx/releases/core)
Dustin Lam4e42fb12021-07-30 17:04:03 -070019 - [DataStore](https://developer.android.com/topic/libraries/architecture/datastore)
Dustin Lameec21a42020-10-13 15:12:26 -070020 - [Fragment](https://developer.android.com/guide/components/fragments)
Dustin Lam841bb082020-12-17 18:13:34 +000021 - [Lifecycle](https://developer.android.com/topic/libraries/architecture/lifecycle)
Dustin Lameec21a42020-10-13 15:12:26 -070022 - [Navigation](https://developer.android.com/guide/navigation)
Dustin Lamd6009c32020-08-13 11:51:05 -070023 - [Paging](https://developer.android.com/topic/libraries/architecture/paging)
24 - [Room](https://developer.android.com/topic/libraries/architecture/room)
25 - [WorkManager](https://developer.android.com/topic/libraries/architecture/workmanager)
Rahul Ravikumar10efcea2020-07-16 15:52:37 -070026
Rahul Ravikumar8f1880f2020-08-25 11:39:24 -070027Not sure where to start? Take a look at the official [feature/bug bounty list](http://goo.gle/androidx-bug-bounty).
28
Rahul Ravikumar10efcea2020-07-16 15:52:37 -070029Our 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.
30
Alan Viverette63ba82e2022-04-25 11:24:03 -040031## Getting started
Rahul Ravikumar10efcea2020-07-16 15:52:37 -070032
Alan Viverette63ba82e2022-04-25 11:24:03 -040033We have tried to make contributing to androidx a lot easier with this new setup. Just start by
34creating a fork of the [androidx/androidx](https://github.com/androidx/androidx) GitHub repository.
Rahul Ravikumar10efcea2020-07-16 15:52:37 -070035
Alan Viverette63ba82e2022-04-25 11:24:03 -040036### One-time setup
Rahul Ravikumar10efcea2020-07-16 15:52:37 -070037
Alan Viverette63ba82e2022-04-25 11:24:03 -040038- Click on the `Actions` tab in the forked `androidx` repository, and enable the use of `Workflows`.
Rahul Ravikumar10efcea2020-07-16 15:52:37 -070039
40- Download and install JDK 11, if you don’t have it already.
41
Alan Viverette63ba82e2022-04-25 11:24:03 -040042 Note the installation directory. If you already have JDK 11 installed and set as default, you can
43 find this with `which javac`.
44
45- Download and install [Android Studio](https://developer.android.com/studio) if you don't have it
46 already. Then, locate your Android SDK directory at `Tools > SDK Manager > Android SDK Location`.
47
48 If you already have the SDK installed or don't plan on using Android Studio, just note the
49 SDK directory.
50
51- Download and install the NDK. You can either do this using the command-line `sdkmanager` or from
52 Android Studio using `Tools > SDK Manager`, checking `Show Package Details`, and expanding `NDK`.
Dustin Lam2fce3fd2021-11-17 12:16:03 -080053
54 ```bash
55 sdkmanager --install "ndk;23.1.7779620"
Yigit Boyar19d16da2022-04-15 14:50:33 -070056 sdkmanager --install "cmake;3.22.1" --channel=3 #channel 3 is the canary channel
Dustin Lam2fce3fd2021-11-17 12:16:03 -080057 ```
Alan Viverette63ba82e2022-04-25 11:24:03 -040058
59 Either way, note the installation directory. This will typically be inside your Android SDK
60 directory as `/ndk/23.1.7779620`.
Dustin Lam2fce3fd2021-11-17 12:16:03 -080061
Alan Viverette63ba82e2022-04-25 11:24:03 -040062- Next, set up the following environment variables:
Rahul Ravikumar10efcea2020-07-16 15:52:37 -070063
64 ```bash
65 # You could also add this to your .{bash|zsh}rc file.
Alan Viverette63ba82e2022-04-25 11:24:03 -040066 export JAVA_HOME="location of JDK 11 directory"
67 export ANDROID_SDK_ROOT="location of the Android SDK directory"
68 export ANDROID_NDK_ROOT="location of the Android NDK directory containing version 23.1.7779620"
Rahul Ravikumar10efcea2020-07-16 15:52:37 -070069 ```
70
Alan Viverette63ba82e2022-04-25 11:24:03 -040071### Checkout and importing a project
Rahul Ravikumar10efcea2020-07-16 15:52:37 -070072
73The list of folders that can be contributed to, using the GitHub repository are:
74
75```
76androidx
Simon Schillere1e83c62020-10-14 09:59:07 -070077 -- activity
Alan Viverette63ba82e2022-04-25 11:24:03 -040078 -- appcompat
Dustin Lam7c04f762020-12-11 17:36:12 -080079 -- biometric
Dustin Lamc93a99d2020-12-31 00:08:18 +000080 -- compose/compiler
jimgoog51f8af32021-08-11 17:45:19 +000081 -- compose/runtime
Alan Viverette63ba82e2022-04-25 11:24:03 -040082 -- core
Dustin Lam4e42fb12021-07-30 17:04:03 -070083 -- datastore
Simon Schillere1e83c62020-10-14 09:59:07 -070084 -- fragment
Dustin Lam841bb082020-12-17 18:13:34 +000085 -- lifecycle
Simon Schillere1e83c62020-10-14 09:59:07 -070086 -- navigation
Dustin Lamd6009c32020-08-13 11:51:05 -070087 -- paging
Rahul Ravikumar10efcea2020-07-16 15:52:37 -070088 -- room
89 -- work
90```
91
Alan Viverette053e7e62020-12-15 10:22:06 -050092**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 -070093
Frieder Bluemle07c59542020-10-28 23:24:13 -070094Fork the [androidx/androidx](https://github.com/androidx/androidx) repository.
Rahul Ravikumar10efcea2020-07-16 15:52:37 -070095
Aurimas4b939852020-07-23 23:57:49 +000096We recommend cloning using blob filter to reduce checkout size:
97```bash
Dustin Lamf66d2aa2020-09-10 19:21:50 -070098git clone https://github.com/YOUR_USERNAME/androidx.git
Aurimas4b939852020-07-23 23:57:49 +000099```
100
Rahul Ravikumare6857b32020-10-15 22:13:38 +0000101---
102
103> NOTE: If you are low on disk space, then you can use the following command to save some space in your checkout. :point_left:
104
105```bash
106# Filters any blob > 10M
107git clone --filter=blob:limit=10M https://github.com/YOUR_USERNAME/androidx.git
108```
109---
110
Rahul Ravikumar10efcea2020-07-16 15:52:37 -0700111Let’s assume that you want to make a contribution to Room. The first step is to launch Android Studio and import the Room project.
112
113First launch Android Studio using:
114
115```bash
116cd androidx/room
117# This will automatically launch the `room` project in Android Studio.
118./gradlew studio
119```
120
121The studio task automatically downloads the correct version of Android Studio that matches the Android Gradle Plugin version.
122
Alan Viverette63ba82e2022-04-25 11:24:03 -0400123### Making changes
Rahul Ravikumar10efcea2020-07-16 15:52:37 -0700124
125You 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.
126
127### Validating changes locally
128
129Before 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.
130
131Apart from this, there are checks that ensure developers follow the Android coding standards & guidelines.
132
133To make sure that your code passes all the above checks & tests you can run:
134
135```bash
136# Switch to the `room` directory or the project you are working on.
137cd room
138# Run device side and host side tests
139./gradlew test connectedCheck
140
141# Run additional checks
142./gradlew buildOnServer
143
144# If you are testing on an emulator, you can disable benchmark tests as
145# follows since they require a real device to run
146./gradlew \
147 test connectedCheck \
148 -x :room:room-benchmark:cC \
149 -x :room:integration-tests:room-incremental-annotation-processing:test
150```
151
152Once your changes look good, you can push them to your fork of the repository. Now you are ready to make a pull request.
153
154**Note:** When you make changes to an API, you need to run:
155
156```
157./gradlew updateApi
158```
159
Alan Viverette053e7e62020-12-15 10:22:06 -0500160If 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 -0700161
162This helps the AndroidX project keep track of API changes and avoid inadvertently adding APIs or introduce backwards incompatible changes.
163
Ahmed El-Helwa82b8132020-08-05 00:19:35 +0000164**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.
165
Rahul Ravikumar10efcea2020-07-16 15:52:37 -0700166**Note: CI build will already check for these but it is best to run them locally to speedup the process.**
167
Alan Viverette63ba82e2022-04-25 11:24:03 -0400168### Making a pull request
Rahul Ravikumar10efcea2020-07-16 15:52:37 -0700169
Frieder Bluemle07c59542020-10-28 23:24:13 -0700170To 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 -0700171
172Then click on the compare across forks and select your forked repository as the HEAD repository. Then click Create.
173
174All pull requests **must follow** the following conventions.
175
1761. The pull request includes a short description of the change, and a longer detailed description.
1772. Include a Test stanza in the pull request which describes the steps followed by the developer to test the changes.
1783. 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.
179
180Here is an example:
181
182```
183Short description for the change.
184
185Longer explanation for the change.
186
187Test: A test stanza. For e.g. /gradlew test connectedCheck
188Fixes: b/<bugId> if applicable
189```
190
Alan Viverette63ba82e2022-04-25 11:24:03 -0400191### Pull request workflow
Rahul Ravikumar10efcea2020-07-16 15:52:37 -0700192
Alan Viverette053e7e62020-12-15 10:22:06 -0500193AndroidX 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 -0700194
195Here is what a typical pull request workflow looks like:
196
Alan Viverette053e7e62020-12-15 10:22:06 -05001971. Create a GitHub pull request from **your forked repository** to the androidx-main branch on GitHub.
Rahul Ravikumar10efcea2020-07-16 15:52:37 -07001982. Sign the Contributor’s License Agreement at https://cla.developers.google.com/ to get @googlebot to give you the `cla: yes` label.
1993. 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.
2004. Once the changes look good, a Googler will Approve your pull request on GitHub.
2015. Your PR will be **tested using GitHub workflows**. You can monitor these GitHub workflows by using the Actions tab in your forked repository.
2026. 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 -05002037. 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 -07002048. 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.
205
206### Running into problems?
207
208- 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).