Android compile from sources

From Toshiba AC100 wiki
Jump to navigation Jump to search

How to compile Android CM for AC100 from sources

Build Enviroment

I use openSUSE 13.1 x64 as build enviroment. When installing 13.1 dont forget to choose this software package patterns:

Base Development
C/C++ Development
Java Development
Linux Kernel Development
Python Development
Perl Development

Or install patterns from terminal:

sudo zypper install -t devel_basis pattern devel_C_C++ devel_java devel_kernel devel_perl devel_python

Also add some additional packages:


Install Oracle JDK following this guide [ TODO: try java-1_7_0-openjdk-devel ]

Get Sources

Download repo tool and place it into path, latest repo url is here:

Set your name and e-mail in git:

git config --global "John Doe"
git config --global [email protected]

Create directory for source for example:

mkdir ~/src/cm-ac100
cd ~/src/cm-ac100

Initialize jellybean repo:

repo init -u git:// -b jellybean
curl --create-dirs -L -o .repo/local_manifests/local_manifest.xml -O -L

Initialize 11.0 repo:

repo init -u git:// -b cm-11.0-ac100

for 10.2 use this:

repo init -u git:// -b cm-10.2-ac100

for 10.1 use this:

repo init -u git:// -b cm-10.1-ac100

After repo initialized download sources:

repo sync -j16

If you see "unable to connect to" errors, disable firewall and try sync again.


After all sources downloaded, prepare android build enviroment:

source ./build/

Download prebuilt packages:

cd vendor/cm
cd ../..

Choose AC100 configuration:

lunch cm_ac100-userdebug

Start source compilation:

make -j16 otapackage 2>&1 | tee ~/src/my-compile-log

When you need to clean compiled binaries:

make -j16 clobber

Rebuild after code change

For example something is modified in device/toshiba/paz00-common/audio but rebuilding whole base is too long, here is how to rebuild only changed part

cd ~/src/cm-11.0
make installclean
cd device/toshiba/paz00-common/audio
mm -B
cd ~/src/cm-11.0
make otapackage

Multiple Java versions

I use openSUSE, update-alternatives may be different for other dists.
Use update-alternatives to switch to specific version

 1 #!/bin/sh
 2 # cm-11
 3 ##sudo /usr/sbin/update-alternatives --set java /usr/java/jdk1.6.0_35/bin/java
 4 ##sudo /usr/sbin/update-alternatives --set javac /usr/java/jdk1.6.0_35/bin/javac
 5 # cm-12+
 6 #sudo /usr/sbin/update-alternatives --set java /usr/lib64/jvm/jre-1.7.0-openjdk/bin/java
 7 #sudo /usr/sbin/update-alternatives --set javac /usr/lib64/jvm/java-1.7.0-openjdk/bin/javac
 8 # cm-14+
 9 sudo /usr/sbin/update-alternatives --set java /usr/lib64/jvm/jre-1.8.0-openjdk/bin/java
10 sudo /usr/sbin/update-alternatives --set javac /usr/lib64/jvm/java-1.8.0-openjdk/bin/javac

Use .bashrc or .profile

# cm-11
##export JAVA_HOME=/usr/java/jdk1.6.0_35
##export ANDROID_JAVA_HOME=/usr/java/jdk1.6.0_35
# cm-12+
##export JAVA_HOME=/usr/lib64/jvm/java-1.7.0-openjdk/
##export ANDROID_JAVA_HOME=/usr/lib64/jvm/java-1.7.0-openjdk/
# cm-14+
export JAVA_HOME=/usr/lib64/jvm/java-1.8.0-openjdk/
export ANDROID_JAVA_HOME=/usr/lib64/jvm/java-1.8.0-openjdk/