Tag Archives: sdk

Building Android SDK on Fedora 20

See Building Android Tools and Fedora Android Setup for reference. Commands like yum have to be sudo’ed or run by root, all other commands should be run by an ordinary user.

Make sure you have about 30-100 Gigs HD space available (depending on on what you build).

Since fedora 20 starts out with kernel 3.11, I updated to 3.13 (probably not necessary, but I really like 3.13). Reboot if you updated your kernel:

yum update

Install android emulator 32 bit packages:

yum install glibc.i686 glibc-devel.i686 libstdc++.i686 zlib-devel.i686 ncurses-devel.i686 libX11-devel.i686 libXrender.i686 libXrandr.i686

Install other needed packages:

yum install gcc gcc-c++ gperf flex bison glibc-devel.{x86_64,i686} zlib-devel.{x86_64,i686} ncurses-devel.i686 libsx-devel readline-devel.i686 perl-Switch git gpg schedtool

Make sure you have javac:

yum install java-1.7.0-openjdk-devel.x86_64

Alternatively, you can install all required packages with one command:

yum install glibc.i686 glibc-devel.i686 libstdc++.i686 zlib-devel.i686 \
ncurses-devel.i686 libX11-devel.i686 libXrender.i686 libXrandr.i686 gcc gcc-c++ gperf \
flex bison glibc-devel.{x86_64,i686} zlib-devel.{x86_64,i686} ncurses-devel.i686 libsx-devel \
readline-devel.i686 perl-Switch git gpg java-1.7.0-openjdk-devel.x86_64 schedtool

Install repo:

mkdir ~/bin
curl http://commondatastorage.googleapis.com/git-repo-downloads/repo > ~/bin/repo
chmod a+x ~/bin/repo

Make sure repo works (on my freshly installed fedora 20, ~/bin was already in the path).

Check out sources. repo sync can take a long time. Another example for -g would be -g all,-notdefault,-device,-mips,-eclipse,-darwin to omit builds you probably don’t need. You might also adapt the -b flag for another android version (e.g. -b android-sdk-4.4.2_r1), but branches other than master might not support building on Open JDK 7. Also append --config-name if you want to change your git developer name.

mkdir ~/android
cd ~/android
repo init -u https://android.googlesource.com/platform/manifest -g all,-notdefault
repo sync

Create the cache:

echo "export USE_CCACHE=1" >> ~/.bashrc
export USE_CCACHE=1
prebuilts/misc/linux-x86/ccache/ccache -M 25G

Use JDK 7:

echo "export EXPERIMENTAL_USE_JAVA7=true" >> ~/.bashrc
export EXPERIMENTAL_USE_JAVA7=true

Build (adjust make -jn for the number of cores / hardware threads in your machine). The code here juse uses the number of available CPUs. According to the Replicant SDK build instructions best results on fast hardware will come with -j9, -j16 and -j32:

. build/envsetup.sh
lunch sdk-eng
parallel_tasks=$(echo "$(grep 'processor' /proc/cpuinfo | wc -l ) + 1" | bc)
make -j$parallel_tasks sdk

Some output files are located at:

out/host/linux-x86/sdk/
out/host/linux-x86/bin/

Your SDK zip should be located here: out/host/linux-x86/sdk/android-sdk_eng.<username>_linux-x86.zip

Notes

If you’re only interested in adb and fastboot (e.g., for bootstrapping a cyanogen mod device build), then just make those:

make fastboot adb

On my machine the adb and fastboot didn’t work very well, but the ones from a Replicant SDK build did.