blob: d7aa0e9c48fc81db62edfea7dc11f3e5f61bce63 [file] [log] [blame] [view]
Aurimas Liutikas09cb6c92019-05-13 14:05:38 -07001# Android Jetpack
2
3Jetpack 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.
4
5Jetpack 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.
6
7Our official AARs and JARs binaries are distributed through [Google Maven](https://dl.google.com/dl/android/maven2/index.html).
8
9You can learn more about using it from [Android Jetpack landing page](https://developer.android.com/jetpack).
10
11# Contribution Guide
Aurimas Liutikase2fa3862017-02-01 13:24:41 -080012## Accepted Types of Contributions
Chris Craik5d6680342018-07-20 16:39:25 -070013* 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 -080014* Each bug fix is expected to come with tests
15* Fixing spelling errors
16* Updating documentation
17* Adding new tests to the area that is not currently covered by tests
Aurimas Liutikasa8417542018-07-19 17:12:32 -070018* 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 -080019
Aurimas Liutikasa8417542018-07-19 17:12:32 -070020We **are not** currently accepting new modules.
Aurimas Liutikase2fa3862017-02-01 13:24:41 -080021
22## Checking Out the Code
Aurimas Liutikasdad83692017-02-10 09:37:37 -080023**NOTE: You will need to use Linux or Mac OS. Building under Windows is not currently supported.**
24
Aurimas Liutikas09cb6c92019-05-13 14:05:38 -0700251. 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))
26
27
28 mkdir ~/bin
29 PATH=~/bin:$PATH
30 curl https://storage.googleapis.com/git-repo-downloads/repo > ~/bin/repo
31 chmod a+x ~/bin/repo
32
332. Configure Git with your real name and email address.
34
35
36 git config --global user.name "Your Name"
37 git config --global user.email "[email protected]"
38
393. Create a directory for your checkout (it can be any name)
40
41
42 mkdir androidx-master-dev
43 cd androidx-master-dev
44
454. Use `repo` command to initialize the repository.
46
Aurimas Liutikase2fa3862017-02-01 13:24:41 -080047
Aurimas Liutikasa8417542018-07-19 17:12:32 -070048 repo init -u https://android.googlesource.com/platform/manifest -b androidx-master-dev
Aurimas Liutikase2fa3862017-02-01 13:24:41 -080049
Aurimas Liutikas09cb6c92019-05-13 14:05:38 -0700505. 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 6GB):
Dake Gua40c6652018-07-23 11:36:12 -070051
Aurimas Liutikase2fa3862017-02-01 13:24:41 -080052
53 repo sync -j8 -c
54
55You will use this command to sync your checkout in the future - its similar to `git fetch`
56
57
58## Using Android Studio
Drew Hannay6d6535bb2019-03-11 12:30:58 -070059To open the project with the specific version of Android Studio recommended for developing:
60
61 cd path/to/checkout/frameworks/support/
62 ./studiow
63
64and accept the license agreement when prompted. Now you're ready edit, run, and test!
Aurimas Liutikase2fa3862017-02-01 13:24:41 -080065
66If you get “Unregistered VCS root detected” click “Add root” to enable git integration for Android Studio.
67
68If you see any warnings (red underlines) run `Build > Clean Project`.
69
Jeff Gastone3be4aa2018-01-17 19:11:11 -050070## Builds
71### Full Build (Optional)
Aurimas Liutikasa8417542018-07-19 17:12:32 -070072You 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 -080073
74 cd path/to/checkout/frameworks/support/
75 ./gradlew createArchive
76
Chris Craik5d6680342018-07-20 16:39:25 -070077### Testing modified AndroidX Libraries to in your App
78You can build maven artifacts locally, and test them directly in your app:
79
80 ./gradlew createArchive
81
82And put in your **project** `build.gradle` file:
83
Aurimas Liutikas0a469432019-05-30 14:51:14 -070084 handler.maven { url '/path/to/checkout/out/androidx/build/support_repo/' }
Jeff Gastone3be4aa2018-01-17 19:11:11 -050085
Aurimas Liutikasa3163ec2019-05-10 09:54:08 -070086### Continuous integration
Aurimas Liutikas09cb6c92019-05-13 14:05:38 -070087[Our continuous integration system](https://ci.android.com/builds/branches/aosp-androidx-master-dev/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 -070088
Aurimas Liutikase2fa3862017-02-01 13:24:41 -080089## Running Tests
90
91### Single Test Class or Method
921. Open the desired test file in Android Studio.
932. Right-click on a test class or @Test method name and select `Run FooBarTest`
94
95### Full Test Package
961. In the project side panel open the desired module.
972. Find the directory with the tests
Aurimas Liutikasa8417542018-07-19 17:12:32 -0700983. Right-click on the directory and select `Run androidx.foobar`
Aurimas Liutikase2fa3862017-02-01 13:24:41 -080099
100## Running Sample Apps
Chris Craik5d6680342018-07-20 16:39:25 -0700101The 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 -0800102
Chris Craik5d6680342018-07-20 16:39:25 -0700103These applications are named either `<libraryname>-integration-tests-testapp`, or `support-\*-demos` (e.g. `support-4v-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 -0800104
Dake Gua40c6652018-07-23 11:36:12 -0700105## Password and Contributor Agreement before making a change
106Before uploading your first contribution, you will need setup a password and agree to the contribution agreement:
107
108Generate a HTTPS password:
109https://android-review.googlesource.com/new-password
110
111Agree to the Google Contributor Licenses Agreement:
112https://android-review.googlesource.com/settings/new-agreement
113
Aurimas Liutikase2fa3862017-02-01 13:24:41 -0800114## Making a change
115 cd path/to/checkout/frameworks/support/
116 repo start my_branch_name .
117 (make needed modifications)
118 git commit -a
119 repo upload --current-branch .
120
121If you see the following prompt, choose `always`:
122
123 Run hook scripts from https://android.googlesource.com/platform/manifest (yes/always/NO)?
124
Chris Craik5d6680342018-07-20 16:39:25 -0700125If the upload succeeds, you'll see output like:
126
127 remote:
128 remote: New Changes:
129 remote: https://android-review.googlesource.com/c/platform/frameworks/support/+/720062 Further README updates
130 remote:
131
132To edit your change, use `git commit --amend`, and re-upload.
133
Aurimas Liutikase2fa3862017-02-01 13:24:41 -0800134## Getting reviewed
135* After you run repo upload, open [r.android.com](http://r.android.com)
136* Sign in into your account (or create one if you do not have one yet)
Aurimas Liutikasa8417542018-07-19 17:12:32 -0700137* 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 -0800138
Aurimas Liutikasc0f9d5b2018-08-21 11:40:59 -0700139## Handling binary dependencies
Jeff Gaston7fa20792019-04-11 19:52:17 -0400140AndroidX 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).