blob: 97bc39176a73c2950ec3bf07ca44d7e487092ebc [file] [log] [blame] [view]
Aurimas Liutikasa8417542018-07-19 17:12:32 -07001# AOSP AndroidX Contribution Guide
Aurimas Liutikase2fa3862017-02-01 13:24:41 -08002## Accepted Types of Contributions
Chris Craik5d6680342018-07-20 16:39:25 -07003* 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 -08004* Each bug fix is expected to come with tests
5* Fixing spelling errors
6* Updating documentation
7* Adding new tests to the area that is not currently covered by tests
Aurimas Liutikasa8417542018-07-19 17:12:32 -07008* 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 -08009
Aurimas Liutikasa8417542018-07-19 17:12:32 -070010We **are not** currently accepting new modules.
Aurimas Liutikase2fa3862017-02-01 13:24:41 -080011
12## Checking Out the Code
Aurimas Liutikasdad83692017-02-10 09:37:37 -080013**NOTE: You will need to use Linux or Mac OS. Building under Windows is not currently supported.**
14
Aurimas Liutikase2fa3862017-02-01 13:24:41 -080015Follow the [“Downloading the Source”](https://source.android.com/source/downloading.html) guide to install and set up `repo` tool, but instead of running the listed `repo` commands to initialize the repository, run the folowing:
16
Aurimas Liutikasa8417542018-07-19 17:12:32 -070017 repo init -u https://android.googlesource.com/platform/manifest -b androidx-master-dev
Aurimas Liutikase2fa3862017-02-01 13:24:41 -080018
Dake Gua40c6652018-07-23 11:36:12 -070019The first time you initialize the repository, it will ask for user name and email.
20
Chris Craik5d6680342018-07-20 16:39:25 -070021Now 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 3GB):
Aurimas Liutikase2fa3862017-02-01 13:24:41 -080022
23 repo sync -j8 -c
24
25You will use this command to sync your checkout in the future - its similar to `git fetch`
26
27
28## Using Android Studio
Drew Hannay6d6535bb2019-03-11 12:30:58 -070029To open the project with the specific version of Android Studio recommended for developing:
30
31 cd path/to/checkout/frameworks/support/
32 ./studiow
33
34and accept the license agreement when prompted. Now you're ready edit, run, and test!
Aurimas Liutikase2fa3862017-02-01 13:24:41 -080035
36If you get “Unregistered VCS root detected” click “Add root” to enable git integration for Android Studio.
37
38If you see any warnings (red underlines) run `Build > Clean Project`.
39
Jeff Gastone3be4aa2018-01-17 19:11:11 -050040## Builds
41### Full Build (Optional)
Aurimas Liutikasa8417542018-07-19 17:12:32 -070042You 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 -080043
44 cd path/to/checkout/frameworks/support/
45 ./gradlew createArchive
46
Chris Craik5d6680342018-07-20 16:39:25 -070047### Testing modified AndroidX Libraries to in your App
48You can build maven artifacts locally, and test them directly in your app:
49
50 ./gradlew createArchive
51
52And put in your **project** `build.gradle` file:
53
Jeff Gaston7fa20792019-04-11 19:52:17 -040054 handler.maven { url '/path/to/checkout/out/support/build/support_repo/' }
Jeff Gastone3be4aa2018-01-17 19:11:11 -050055
Aurimas Liutikase2fa3862017-02-01 13:24:41 -080056## Running Tests
57
58### Single Test Class or Method
591. Open the desired test file in Android Studio.
602. Right-click on a test class or @Test method name and select `Run FooBarTest`
61
62### Full Test Package
631. In the project side panel open the desired module.
642. Find the directory with the tests
Aurimas Liutikasa8417542018-07-19 17:12:32 -0700653. Right-click on the directory and select `Run androidx.foobar`
Aurimas Liutikase2fa3862017-02-01 13:24:41 -080066
67## Running Sample Apps
Chris Craik5d6680342018-07-20 16:39:25 -070068The 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 -080069
Chris Craik5d6680342018-07-20 16:39:25 -070070These 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 -080071
Dake Gua40c6652018-07-23 11:36:12 -070072## Password and Contributor Agreement before making a change
73Before uploading your first contribution, you will need setup a password and agree to the contribution agreement:
74
75Generate a HTTPS password:
76https://android-review.googlesource.com/new-password
77
78Agree to the Google Contributor Licenses Agreement:
79https://android-review.googlesource.com/settings/new-agreement
80
Aurimas Liutikase2fa3862017-02-01 13:24:41 -080081## Making a change
82 cd path/to/checkout/frameworks/support/
83 repo start my_branch_name .
84 (make needed modifications)
85 git commit -a
86 repo upload --current-branch .
87
88If you see the following prompt, choose `always`:
89
90 Run hook scripts from https://android.googlesource.com/platform/manifest (yes/always/NO)?
91
Chris Craik5d6680342018-07-20 16:39:25 -070092If the upload succeeds, you'll see output like:
93
94 remote:
95 remote: New Changes:
96 remote: https://android-review.googlesource.com/c/platform/frameworks/support/+/720062 Further README updates
97 remote:
98
99To edit your change, use `git commit --amend`, and re-upload.
100
Aurimas Liutikase2fa3862017-02-01 13:24:41 -0800101## Getting reviewed
102* After you run repo upload, open [r.android.com](http://r.android.com)
103* Sign in into your account (or create one if you do not have one yet)
Aurimas Liutikasa8417542018-07-19 17:12:32 -0700104* 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 -0800105
Aurimas Liutikasc0f9d5b2018-08-21 11:40:59 -0700106## Handling binary dependencies
Jeff Gaston7fa20792019-04-11 19:52:17 -0400107AndroidX 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).