[TUT] Configuring Arch Linux to build Android
Arch Linux is a rolling release distribution, but Android requires you to have jdk6 (or openjdk6) and python2 to build it. It took me some time to setup everything, and I hope this guide will be useful to anyone who's trying to do the same.
The ArchWiki is a bit outdated. Among other things, it suggests changing the "python" symlink to point to python2, which I didn't want to do as it could cause problems ("python" is supposed to point to python3). Also, Arch Linux uses openjdk7, so you'd have to downgrade to openjdk6 (or Oracle's jdk6) - which isn't mentioned in the Wiki, and is something I'd rather avoid as I want to keep using the latest version.
Basically, I'd like to share this here for now to get some input, and later update the ArchWiki.
0- Quick note about this guide
I think it's pretty safe to assume you're familiar with the terminal.
Also note that this guide will not really talk about how to actually build Android, it's focused on setting up your Arch distro to do so in an easy way.
The ArchWiki covers installing the Android SDK and ADB
You'll need these packages for building Android:
git gnupg flex bison gperf sdl wxgtk squashfs-tools curl ncurses zlib schedtool perl-switch zip unzip
And for 64 bit systems (make sure multilib is enabled):
lib32-zlib lib32-ncurses lib32-readline gcc-libs-multilib gcc-multilib lib32-gcc-libs
You also need the "repo" utility, which is available in the AUR
2- Setting up Java
The AUR has packages that should install alongside openjdk7, but that didn't work for me and I found it easier to simply install jdk6 independently of pacman's packages.
To do so, download the latest Linux .bin file
(jdk-6u45-linux-x64.bin), and place it in /opt (run a root shell, "sudo bash"):
Make it executable and run it as root:
chmod +x jdk-6u45-linux-x64.bin
We'll be updating our path before building to use this version.
3- Setting up Python
We're going to create a python symlink to python2, and place it in /opt/android-build. We'll use this later by updating our path when necessary.
4- (Temporarily) Setting up our PATH to test if everything's fine
ln -s $(which python2) python
We just installed jdk6 and made a symlink to python2, but we still need to update our path. In this step, we'll do that in order to test that everything's fine:
Make sure jdk6 and python2 are being used:
echo -n $(python -V)
echo -n $(java -version)
The output should be similar to:
5- Make a build script (or just build).
java version "1.6.xx"
Java(TM) SE Runtime Environment (build 1.6.xx)
Java HotSpot(TM) 64-Bit Server VM (build 20.45-b01, mixed mode)
I'd highly suggest making a build script and placing it in ~/bin. You can then easily run it, and it will take care of everything.
Otherwise, you can run this in the terminal every time before building:
And then proceed normally, for example:
time make -j6 bacon
This is my (trimmed down to remove some git revert checks) personal build script, you can modify it to fit your needs. The working directory is your home folder, change the "path" variable around the middle if yours is different.
To set it up:
<copy the above script, press SHIFT + INSERT to paste, and CTRL+X followed by "Y" to save>
chmod +x ~/bin/build
Usage: build [OPTIONS]
-h, --help show this screen
-s, --sync run repo sync before building
-c, --clean make clean
These web pages helped me a lot.