blob: d4fdb914cfceda6183b6221cd1813d95caa3b8c2 [file] [log] [blame] [view]
Aurimas Liutikas09cb6c92019-05-13 14:05:38 -07001# Android Jetpack
2
Daz DeBoerf999a872022-02-03 13:02:15 -08003[![Revved up by Gradle Enterprise](https://img.shields.io/badge/Revved%20up%20by-Gradle%20Enterprise-06A0CE?logo=Gradle&labelColor=02303A)](https://ge.androidx.dev)
4
Aurimas Liutikas09cb6c92019-05-13 14:05:38 -07005Jetpack is a suite of libraries, tools, and guidance to help developers write high-quality apps easier. These components help you follow best practices, free you from writing boilerplate code, and simplify complex tasks, so you can focus on the code you care about.
6
7Jetpack comprises the `androidx.*` package libraries, unbundled from the platform APIs. This means that it offers backward compatibility and is updated more frequently than the Android platform, making sure you always have access to the latest and greatest versions of the Jetpack components.
8
Andrea Falcone4a552532020-07-23 14:58:14 -07009Our official AARs and JARs binaries are distributed through [Google Maven](https://maven.google.com).
Aurimas Liutikas09cb6c92019-05-13 14:05:38 -070010
11You can learn more about using it from [Android Jetpack landing page](https://developer.android.com/jetpack).
12
13# Contribution Guide
Dustin Lam40143f72020-07-23 19:47:21 -070014
15For contributions via GitHub, see the [GitHub Contribution Guide](CONTRIBUTING.md).
16
Dustin Lameec21a42020-10-13 15:12:26 -070017Note: The contributions workflow via GitHub is currently experimental - only contributions to the following projects are being accepted at this time:
18* [Activity](activity)
Dustin Lam7c04f762020-12-11 17:36:12 -080019* [Biometric](biometric)
Dustin Lamc93a99d2020-12-31 00:08:18 +000020* [Compose Compiler](compose/compiler)
jimgoog51f8af32021-08-11 17:45:19 +000021* [Compose Runtime](compose/runtime)
Dustin Lam4e42fb12021-07-30 17:04:03 -070022* [DataStore](datastore)
Dustin Lameec21a42020-10-13 15:12:26 -070023* [Fragment](fragment)
Dustin Lam841bb082020-12-17 18:13:34 +000024* [Lifecycle](lifecycle)
Dustin Lameec21a42020-10-13 15:12:26 -070025* [Navigation](navigation)
26* [Paging](paging)
27* [Room](room)
28* [WorkManager](work)
Dustin Lam40143f72020-07-23 19:47:21 -070029
Aurimas Liutikas8df542e2019-12-11 13:42:21 -080030## Code Review Etiquette
31When contributing to Jetpack, follow the [code review etiquette](code-review.md).
32
Aurimas Liutikase2fa3862017-02-01 13:24:41 -080033## Accepted Types of Contributions
Chris Craik5d6680342018-07-20 16:39:25 -070034* Bug fixes - needs a corresponding bug report in the [Android Issue Tracker](https://issuetracker.google.com/issues/new?component=192731&template=842428)
Aurimas Liutikase2fa3862017-02-01 13:24:41 -080035* Each bug fix is expected to come with tests
36* Fixing spelling errors
37* Updating documentation
38* Adding new tests to the area that is not currently covered by tests
Aurimas Liutikasa8417542018-07-19 17:12:32 -070039* New features to existing libraries if the feature request bug has been approved by an AndroidX team member.
Aurimas Liutikase2fa3862017-02-01 13:24:41 -080040
Aurimas Liutikasa8417542018-07-19 17:12:32 -070041We **are not** currently accepting new modules.
Aurimas Liutikase2fa3862017-02-01 13:24:41 -080042
43## Checking Out the Code
Aurimas Liutikasdad83692017-02-10 09:37:37 -080044**NOTE: You will need to use Linux or Mac OS. Building under Windows is not currently supported.**
45
Aurimas Liutikas09cb6c92019-05-13 14:05:38 -0700461. Install `repo` (Repo is a tool that makes it easier to work with Git in the context of Android. For more information about Repo, see the [Repo Command Reference](https://source.android.com/setup/develop/repo))
47
Deepanshu Guptae0633e92019-06-14 15:28:56 +053048```bash
Nate Fischer1dda51c2019-09-17 18:21:29 -070049mkdir ~/bin
50PATH=~/bin:$PATH
51curl https://storage.googleapis.com/git-repo-downloads/repo > ~/bin/repo
52chmod a+x ~/bin/repo
Deepanshu Guptae0633e92019-06-14 15:28:56 +053053```
Aurimas Liutikas09cb6c92019-05-13 14:05:38 -070054
552. Configure Git with your real name and email address.
56
Deepanshu Guptae0633e92019-06-14 15:28:56 +053057```bash
Nate Fischer1dda51c2019-09-17 18:21:29 -070058git config --global user.name "Your Name"
59git config --global user.email "[email protected]"
Deepanshu Guptae0633e92019-06-14 15:28:56 +053060```
Aurimas Liutikas09cb6c92019-05-13 14:05:38 -070061
623. Create a directory for your checkout (it can be any name)
63
Deepanshu Guptae0633e92019-06-14 15:28:56 +053064```bash
Alan Viverette053e7e62020-12-15 10:22:06 -050065mkdir androidx-main
66cd androidx-main
Deepanshu Guptae0633e92019-06-14 15:28:56 +053067```
Aurimas Liutikas09cb6c92019-05-13 14:05:38 -070068
694. Use `repo` command to initialize the repository.
70
Deepanshu Guptae0633e92019-06-14 15:28:56 +053071```bash
Alan Viverette053e7e62020-12-15 10:22:06 -050072repo init -u https://android.googlesource.com/platform/manifest -b androidx-main --partial-clone --clone-filter=blob:limit=10M
Deepanshu Guptae0633e92019-06-14 15:28:56 +053073```
Aurimas Liutikase2fa3862017-02-01 13:24:41 -080074
Kirill Grouchnikova2f4a1d2020-09-24 15:26:54 -0400755. Now your repository is set to pull only what you need for building and running AndroidX libraries. Download the code (and grab a coffee while we pull down the files):
Dake Gua40c6652018-07-23 11:36:12 -070076
Deepanshu Guptae0633e92019-06-14 15:28:56 +053077```bash
Nate Fischer1dda51c2019-09-17 18:21:29 -070078repo sync -j8 -c
Deepanshu Guptae0633e92019-06-14 15:28:56 +053079```
Aurimas Liutikase2fa3862017-02-01 13:24:41 -080080
81You will use this command to sync your checkout in the future - its similar to `git fetch`
82
83
84## Using Android Studio
Drew Hannay6d6535bb2019-03-11 12:30:58 -070085To open the project with the specific version of Android Studio recommended for developing:
86
Nate Fischer1dda51c2019-09-17 18:21:29 -070087```bash
88cd path/to/checkout/frameworks/support/
Aurimas Liutikas8af4dc92020-10-14 15:35:28 -070089ANDROIDX_PROJECTS=MAIN ./gradlew studio
Nate Fischer1dda51c2019-09-17 18:21:29 -070090```
Drew Hannay6d6535bb2019-03-11 12:30:58 -070091
James Shvarts4ad9ce62020-08-21 13:49:14 -040092and accept the license agreement when prompted. Now you're ready to edit, run, and test!
Aurimas Liutikase2fa3862017-02-01 13:24:41 -080093
Aurimas Liutikas8af4dc92020-10-14 15:35:28 -070094You can also the following sets of projects: `ALL`, `MAIN`, `COMPOSE`, or `FLAN`
95
Aurimas Liutikase2fa3862017-02-01 13:24:41 -080096If you get “Unregistered VCS root detected” click “Add root” to enable git integration for Android Studio.
97
98If you see any warnings (red underlines) run `Build > Clean Project`.
99
Jeff Gastone3be4aa2018-01-17 19:11:11 -0500100## Builds
101### Full Build (Optional)
Aurimas Liutikasa8417542018-07-19 17:12:32 -0700102You can do most of your work from Android Studio, however you can also build the full AndroidX library from command line:
Aurimas Liutikase2fa3862017-02-01 13:24:41 -0800103
Nate Fischer1dda51c2019-09-17 18:21:29 -0700104```bash
105cd path/to/checkout/frameworks/support/
106./gradlew createArchive
107```
Aurimas Liutikase2fa3862017-02-01 13:24:41 -0800108
Chris Craik5d6680342018-07-20 16:39:25 -0700109### Testing modified AndroidX Libraries to in your App
110You can build maven artifacts locally, and test them directly in your app:
111
Nate Fischer1dda51c2019-09-17 18:21:29 -0700112```bash
113./gradlew createArchive
114```
Chris Craik5d6680342018-07-20 16:39:25 -0700115
shepshapardcdf858b2019-07-25 11:20:02 -0700116And put the following at the top of your 'repositories' property in your **project** `build.gradle` file:
Chris Craik5d6680342018-07-20 16:39:25 -0700117
Nate Fischer1dda51c2019-09-17 18:21:29 -0700118```gradle
119maven { url '/path/to/checkout/out/androidx/build/support_repo/' }
120```
Jeff Gastone3be4aa2018-01-17 19:11:11 -0500121
Ioana Morarud4beca52021-08-12 14:45:17 +0000122**NOTE: In order to see your changes in the project, you might need to clean your build (`Build > Clean Project` in Android Studio or run `./gradlew clean`).**
123
Aurimas Liutikasa3163ec2019-05-10 09:54:08 -0700124### Continuous integration
Alan Viverette053e7e62020-12-15 10:22:06 -0500125[Our continuous integration system](https://ci.android.com/builds/branches/aosp-androidx-main/grid?) builds all in progress (and potentially unstable) libraries as new changes are merged. You can manually download these AARs and JARs for your experimentation.
Aurimas Liutikasa3163ec2019-05-10 09:54:08 -0700126
Aurimas Liutikase2fa3862017-02-01 13:24:41 -0800127## Running Tests
128
129### Single Test Class or Method
1301. Open the desired test file in Android Studio.
1312. Right-click on a test class or @Test method name and select `Run FooBarTest`
132
133### Full Test Package
1341. In the project side panel open the desired module.
1352. Find the directory with the tests
Aurimas Liutikasa8417542018-07-19 17:12:32 -07001363. Right-click on the directory and select `Run androidx.foobar`
Aurimas Liutikase2fa3862017-02-01 13:24:41 -0800137
138## Running Sample Apps
Chris Craik5d6680342018-07-20 16:39:25 -0700139The AndroidX repository has a set of Android applications that exercise AndroidX code. These applications can be useful when you want to debug a real running application, or reproduce a problem interactively, before writing test code.
Aurimas Liutikase2fa3862017-02-01 13:24:41 -0800140
Ian Lake6b93b4d2020-05-13 22:35:03 +0000141These applications are named either `<libraryname>-integration-tests-testapp`, or `support-\*-demos` (e.g. `support-v4-demos` or `support-leanback-demos`). You can run them by clicking `Run > Run ...` and choosing the desired application.
Aurimas Liutikase2fa3862017-02-01 13:24:41 -0800142
Dake Gua40c6652018-07-23 11:36:12 -0700143## Password and Contributor Agreement before making a change
144Before uploading your first contribution, you will need setup a password and agree to the contribution agreement:
145
146Generate a HTTPS password:
147https://android-review.googlesource.com/new-password
148
149Agree to the Google Contributor Licenses Agreement:
150https://android-review.googlesource.com/settings/new-agreement
151
Aurimas Liutikase2fa3862017-02-01 13:24:41 -0800152## Making a change
Nate Fischer1dda51c2019-09-17 18:21:29 -0700153```bash
154cd path/to/checkout/frameworks/support/
155repo start my_branch_name .
156# make needed modifications...
157git commit -a
158repo upload --current-branch .
159```
Aurimas Liutikase2fa3862017-02-01 13:24:41 -0800160
161If you see the following prompt, choose `always`:
162
Nate Fischer1dda51c2019-09-17 18:21:29 -0700163```
164Run hook scripts from https://android.googlesource.com/platform/manifest (yes/always/NO)?
165```
Aurimas Liutikase2fa3862017-02-01 13:24:41 -0800166
Chris Craik5d6680342018-07-20 16:39:25 -0700167If the upload succeeds, you'll see output like:
168
Nate Fischer1dda51c2019-09-17 18:21:29 -0700169```
170remote:
171remote: New Changes:
172remote: https://android-review.googlesource.com/c/platform/frameworks/support/+/720062 Further README updates
173remote:
174```
Chris Craik5d6680342018-07-20 16:39:25 -0700175
176To edit your change, use `git commit --amend`, and re-upload.
177
Aurimas Liutikase2fa3862017-02-01 13:24:41 -0800178## Getting reviewed
179* After you run repo upload, open [r.android.com](http://r.android.com)
180* Sign in into your account (or create one if you do not have one yet)
Aurimas Liutikasa8417542018-07-19 17:12:32 -0700181* Add an appropriate reviewer (use git log to find who did most modifications on the file you are fixing or check the OWNERS file in the project's directory)
Aurimas Liutikase2fa3862017-02-01 13:24:41 -0800182
Aurimas Liutikasc0f9d5b2018-08-21 11:40:59 -0700183## Handling binary dependencies
Jeff Gaston7fa20792019-04-11 19:52:17 -0400184AndroidX uses git to store all the binary Gradle dependencies. They are stored in `prebuilts/androidx/internal` and `prebuilts/androidx/external` directories in your checkout. All the dependencies in these directories are also available from `google()`, `jcenter()`, or `mavenCentral()`. We store copies of these dependencies to have hermetic builds. You can pull in [a new dependency using our importMaven tool](development/importMaven/README.md).