Note: Based on Android documentation.
This tutorial will allow you to run the build-android.sh
script in the Robolectric repository, resulting in the corresponding Android version's android-all jar.
Repo is a tool that makes it easier to work with Git in the context of Android. For more information about Repo, see the Developing section.
To install Repo make sure you have a bin/ directory in your home directory and that it is included in your path:
$ mkdir ~/bin $ PATH=~/bin:$PATH
Download the Repo tool and ensure that it is executable:
$ curl https://storage.googleapis.com/git-repo-downloads/repo > ~/bin/repo $ chmod a+x ~/bin/repo
After installing Repo, set up your client to access the Android source repository:
Create an empty directory to hold your working files. If you're using MacOS, this has to be on a case-sensitive filesystem. Give it any name you like:
$ mkdir <WORKING_DIRECTORY> $ cd <WORKING_DIRECTORY>
Configure git with your real name and email address. To use the Gerrit code-review tool, you will need an email address that is connected with a registered Google account. Make sure this is a live address at which you can receive messages. The name that you provide here will show up in attributions for your code submissions.
$ git config --global user.name "Your Name" $ git config --global user.email "you@example.com"
On Ubuntu run
$ sudo apt-get install git-core gnupg gnupg-agent flex bison gperf build-essential \ zip curl zlib1g-dev gcc-multilib g++-multilib libc6-dev-i386 \ lib32ncurses5-dev x11proto-core-dev libx11-dev lib32z-dev ccache \ libgl1-mesa-dev libxml2-utils xsltproc unzip libswitch-perl
Now use repo to sync the android source, and then build.
./sync-android.sh <root source location> <android version> <# parallel jobs>
The currently supported Android versions are:
4.1.2_r1
- Jelly Bean API 164.2.2_r1.2
- Jelly Bean MR1 API 174.3_r2
- Jelly Bean MR2 API 184.4_r1
- Kit Kat API 195.0.2_r3
- Lollipop API 215.1.1_r9
- Lollipop MR1 API 226.0.1_r3
- Marshmallow API 237.0.0_r1
- Nougat API 247.1.0_r7
- Nougat MR1 API 258.0.0_r4
- Oreo API 26Beware it can take upwards of 100 GB of space to sync and build.
For more infomation see Downloading and Building
Choose a <# parallel jobs> value roughly equal to # of free cores on your machine. YMMV.
Signing Artifacts: The end of the script will prompt you to sign the new artifacts using GPG. See Performing a Release for instructions on obtaining a GPG key pair.
(Optional) You will be prompted a total of 4 times (once for each artifact). To make this easier, run this command beforehand:
$ gpg-agent --daemon
Finally, in your Robolectric directory run:
$ export SIGNING_PASSWORD=<Passphrase for GPG signing key> $ build-android.sh <Path to AOSP source directory> <android version> <robolectric sub-version>
For Robolectric version 6.0.1_r3-robolectric-0
, android version would be 6.0.1_r3
and robolectric sub-version 0
.