Image for post
Image for post
Basic overview of AOSP

Submitting a patch to AOSP

Google has the AOSP (Android Open Source Project) where you can find most of the source code regarding the Android ecosystem. Gradle Plugins, R8/D8, Lint and many other things are located there.

Submitting a patch is easier than expected. Last year, I’ve submitted my first patch — https://android-review.googlesource.com/c/platform/tools/base/+/783316

So let’s get started and see how we can set up our machine so we can contribute.

Authentication

This only needs to be done once per machine.

Environment setup

So, let’s start by installing repo and making it executable:

wget -q https://storage.googleapis.com/git-repo-downloads/repo \
-O ~/bash/repo
chmod a+x ~/bash/repo

If you’re on Mac you can also install it via brew: brew install repo

Now, we can use repo to initialize and checkout our desired branch — which will take a while:

repo init -u https://android.googlesource.com/platform/manifest \
-b studio-master-dev
repo sync -c -j4 -q

Once everything is done, you can open the project where you want to contribute to with IntelliJ. Everything should be checked in as IntelliJ projects so there’s no need to use the build.gradle files for opening them.

Contributing

repo start <branch_name> .
git add -A
git commit -s

git commit -s will open your default editor where you can place your title and description of your commit. An example would look like this:

short description on first line

more detailed description of your patch,
which is likely to take up multiple lines

Once you’ve entered your commit message you can upload your changes with repo upload. It will create the patch and now you can request reviews.

That’s all.

Final phase

Happy contributing!

Written by

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store