Initializing a Build Environment
The "Getting Started" section describes how to set up your local work environment, how to use Repo to get the Android files, and how to build the files on your machine. To build the Android source files, you will need to use Linux or Mac OS. Building under Windows is not currently supported.
Note: The source download is approximately 6GB in size. You will need 25GB free to complete a single build, and up to 80GB (or more) for a full set of builds.
For an overview of the entire code-review and code-update process, see Life of a Patch.
Setting up a Linux build environment
The Android build is routinely tested in house on recent versions of Ubuntu LTS (10.04), but most distributions should have the required build tools available. Reports of successes or failures on other distributions are welcome.
Note: It is also possible to build Android in a virtual machine. If you are running Linux in a virtual machine, you will need at least 16GB of RAM/swap and 30GB or more of disk space in order to build the Android tree.
In general you will need:
*
Python 2.4 -- 2.7, which you can download from python.org.
*
JDK 6 if you wish to build Gingerbread or newer; JDK 5 for Froyo or older. You can download both from java.sun.com.
*
Git 1.7 or newer. You can find it at git-scm.com.
Detailed instructions for Ubuntu 10.04+ follow.
Installing the JDK
The Sun JDK is no longer in Ubuntu's main package repository. In order to download it, you need to add the appropriate repository and indicate to the system which JDK should be used.
Java 6: for Gingerbread and newer
$ sudo add-apt-repository "deb http://archive.canonical.com/ lucid partner"
$ sudo apt-get update
$ sudo apt-get install sun-java6-jdk
Java 5: for Froyo and older
$ sudo add-apt-repository "deb http://archive.ubuntu.com/ubuntu hardy main multiverse"
$ sudo add-apt-repository "deb http://archive.ubuntu.com/ubuntu hardy-updates main multiverse"
$ sudo apt-get update
$ sudo apt-get install sun-java5-jdk
Installing required packages
64-bit (recommended)
$ sudo apt-get install git-core gnupg flex bison gperf build-essential \
zip curl zlib1g-dev libc6-dev lib32ncurses5-dev ia32-libs \
x11proto-core-dev libx11-dev lib32readline5-dev lib32z-dev \
libgl1-mesa-dev g++-multilib mingw32 tofrodos python-markdown \
libxml2-utils
On newer versions of Ubuntu such as 11.10 you may need to do the following:
$ sudo ln -s /usr/lib/i386-linux-gnu/libX11.so.6 /usr/lib/i386-linux-gnu/libX11.so
32-bit (experimental)
$ sudo apt-get install git-core gnupg flex bison gperf build-essential \
zip curl zlib1g-dev libc6-dev libncurses5-dev x11proto-core-dev \
libx11-dev libreadline6-dev libgl1-mesa-dev tofrodos python-markdown \
libxml2-utils
Configuring USB Access
Under GNU/linux systems (and specifically under Ubuntu systems), regular users can't directly access USB devices by default. The system needs to be configured to allow such access.
The recommended approach is to create a file /etc/udev/rules.d/51-android.rules (as the root user) and to copy the following lines in it.must be replaced by the actual username of the user who is authorized to access the phones over USB.
# adb protocol on passion (Nexus One)
SUBSYSTEM=="usb", ATTR{idVendor}=="18d1", ATTR{idProduct}=="4e12", MODE="0600", OWNER="<username>"
# fastboot protocol on passion (Nexus One)
SUBSYSTEM=="usb", ATTR{idVendor}=="0bb4", ATTR{idProduct}=="0fff", MODE="0600", OWNER="<username>"
# adb protocol on crespo/crespo4g (Nexus S)
SUBSYSTEM=="usb", ATTR{idVendor}=="18d1", ATTR{idProduct}=="4e22", MODE="0600", OWNER="<username>"
# fastboot protocol on crespo/crespo4g (Nexus S)
SUBSYSTEM=="usb", ATTR{idVendor}=="18d1", ATTR{idProduct}=="4e20", MODE="0600", OWNER="<username>"
# adb protocol on maguro (Galaxy Nexus)
SUBSYSTEM=="usb", ATTR{idVendor}=="04e8", ATTR{idProduct}=="6860", MODE="0600", OWNER="<username>"
# fastboot protocol on maguro (Galaxy Nexus)
SUBSYSTEM=="usb", ATTR{idVendor}=="18d1", ATTR{idProduct}=="4e30", MODE="0600", OWNER="<username>"
Those new rules take effect the next time a device is plugged in. It might therefore be necessary to unplug the device and plug it back into the computer.
This is known to work on both Ubuntu Hardy Heron (8.04.x LTS) and Lucid Lynx (10.04.x LTS). Other versions of Ubuntu or other variants of GNU/linux might require different configurations.
Setting up a Mac OS X build environment
To build the Android files in a Mac OS environment, you need an Intel/x86 machine running MacOS 10.6 (Snow Leopard).
Android must be built on a case-sensitive file system because the sources contain files that differ only in case. We recommend that you build Android on a partition that has been formatted with the journaled file system HFS+. HFS+ is required to successfully build Mac OS applications such as the Android Emulator for OS X.
Creating a case sensitive disk image
If you want to avoid partitioning/formatting your hard drive, you can use a case-sensitive disk image instead. To create the image, launch Disk Utility and select "New Image". A size of 25GB is the minimum to complete the build, larger numbers are more future-proof. Using sparse images saves space while allowing to grow later as the need arises. Be sure to select "case sensitive, journaled" as the volume format.
You can also create it from a shell with the following command:
# hdiutil create -type SPARSE -fs 'Case-sensitive Journaled HFS+' -size 40g ~/android.dmg
This will create a .dmg (or possibly a .dmg.sparsefile) file which, once mounted, acts as a drive with the required formatting for Android development. For a disk image named "android.dmg" stored in your home directory, you can add the following to your ~/.bash_profile to mount the image when you execute "mountAndroid":
# mount the android file image
function mountAndroid { hdiutil attach ~/android.dmg -mountpoint /Volumes/android; }
Once mounted, you'll do all your work in the "android" volume. You can eject it (unmount it) just like you would with an external drive.
Installing required packages
*
Install XCode from the Apple developer site. We recommend version 3.1.4 or newer, i.e. gcc 4.2. Version 4.x could cause difficulties. If you are not already registered as an Apple developer, you will have to create an Apple ID in order to download.
*
Install MacPorts from macports.org.
Note: Make sure that /opt/local/bin appears in your path BEFORE /usr/bin. If not, add
export PATH=/opt/local/bin:$PATH
to your ~/.bash_profile.
*
Get make, git, and GPG packages from MacPorts:
$ POSIXLY_CORRECT=1 sudo port install gmake libsdl git-core gnupg
If using Mac OS 10.4, also install bison:
$ POSIXLY_CORRECT=1 sudo port install bison
Reverting from make 3.82
There is a bug in gmake 3.82 that prevents android from building. You can install version 3.81 using MacPorts by taking the following steps:
*
Edit /opt/local/etc/macports/sources.conf and add a line that says
file:///Users/Shared/dports
above the rsync line. Then create this directory:
$ mkdir /Users/Shared/dports
*
In the new dports directory, run
$ svn co --revision 50980 http://svn.macports.org/repository/macports/trunk/dports/devel/gmake/ devel/gmake/
*
Create a port index for your new local repository:
$ portindex /Users/Shared/dports
*
Finally, install the old version of gmake with
$ sudo port install gmake @3.81
Setting a file descriptor limit
On MacOS the default limit on the number of simultaneous file descriptors open is too low and a highly parallel build process may exceed this limit.
To increase the cap, add the following lines to your ~/.bash_profile:
# set the number of open files to be 1024
ulimit -S -n 1024
Downloading the Source Tree
Installing Repo
Repo is a tool that makes it easier to work with Git in the context of Android. For more information about Repo, see Version Control.
To install, initialize, and configure Repo, follow these steps:
*
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 script and ensure it is executable:
$ curl https://dl-ssl.google.com/dl/googlesource/git-repo/repo > ~/bin/repo
$ chmod a+x ~/bin/repo
*
The SHA-1 checksum for repo is e1fd3bef059d152edf4d0522590725d317bc637f
TaintDroid Build Instructions for Android 4.1 (updated Dec 6, 2012)
Disclaimer: Use the TaintDroid and TaintDroid UI research prototypes at your own risk.
TaintDroid is a research prototype and is provided "as is" without warranty or support of any kind, whether expressed or implied. The creators of TaintDroid make no guarantee and hold no responsibility for any damage, injury, loss of property, loss of data, loss of any and all resources, or any negative influence what-so-ever that may result from any and all use of TaintDroid and associated materials. This includes but is not limited to the downloadable software and documentation available from this website. Negative consequences of your usage of TaintDroid and any associated materials are solely your problem and your responsibility.
Before you start:
We created a TaintDroid discussion group for those who are interested in building, installing and running TaintDroid. You may want to post related questions there if answers are not found on this webpage.
If you are looking for a previous release: TaintDroid for Android 2.1 or Android 2.3.
This guide assumes that you have:
* a development computer configured to build the Android source code (see source.android.com for details)
* a Nexus S or a Galaxy Nexus (or you can use the Android emulator)
* and an unlocked bootloader (refer to "Unlocking the bootloader" section in the AOSP building guide. Please note that this will void your warranty.)
It is strongly recommended that you use the nandroid tool provided in a custom recovery firmware such as ClockWorkMod to backup your current system before flashing new images to your device.
Step 1: Get the Android source code
TaintDroid uses the "android-4.1.1_r6" tag of the Android source code. Follow the instructions on source.android.com for obtaining and building Android. Use the "-b android-4.1.1_r6" branch option for repo when checking out the source code.
If you are already familiar with getting and building the Android source code, the following commands summarize the steps:
% mkdir -p ~/tdroid/tdroid-4.1.1_r6
% cd ~/tdroid/tdroid-4.1.1_r6
% repo init -u https://android.googlesource.com/platform/manifest -b android-4.1.1_r6
% repo sync
... wait
Note: At this point, it is recommended that you build Android without any modifications. This will ensure that any build errors for your environment are resolved and are not confused with TaintDroid build errors. For example:
% . build/envsetup.sh
% lunch 1
% make -j4
... wait
% emulator
... ensure the build works
Step 2: Get the TaintDroid source code
Download the TaintDroid 4.1 local_manifest.xml and place it in ~/tdroid/tdroid-4.1.1_r6/.repo or copy and paste the following content into .repo/local_manifest.xml.
<manifest>
<remote name="github" fetch="git://github.com" />
<remove-project name="platform/dalvik"/>
<project path="dalvik" remote="github" name="TaintDroid/android_platform_dalvik" revision="taintdroid-4.1.1_r6"/>
<remove-project name="platform/libcore"/>
<project path="libcore" remote="github" name="TaintDroid/android_platform_libcore" revision="taintdroid-4.1.1_r6"/>
<remove-project name="platform/frameworks/base"/>
<project path="frameworks/base" remote="github" name="TaintDroid/android_platform_frameworks_base" revision="taintdroid-4.1.1_r6"/>
<remove-project name="platform/frameworks/native"/>
<project path="frameworks/native" remote="github" name="TaintDroid/android_platform_frameworks_native" revision="taintdroid-4.1.1_r6"/>
<remove-project name="platform/system/vold"/>
<project path="system/vold" remote="github" name="TaintDroid/android_platform_system_vold" revision="taintdroid-4.1.1_r6"/>
<remove-project name="platform/system/core"/>
<project path="system/core" remote="github" name="TaintDroid/android_platform_system_core" revision="taintdroid-4.1.1_r6"/>
<remove-project name="device/samsung/crespo"/>
<project path="device/samsung/crespo" remote="github" name="TaintDroid/android_device_samsung_crespo" revision="taintdroid-4.1.1_r6"/>
<remove-project name="device/samsung/tuna"/>
<project path="device/samsung/tuna" remote="github" name="TaintDroid/android_device_samsung_tuna" revision="taintdroid-4.1.1_r6"/>
<project path="packages/apps/TaintDroidNotify" remote="github" name="TaintDroid/android_platform_packages_apps_TaintDroidNotify"
revision="taintdroid-4.1.1_r6"/>
</manifest>
Next, pull the source code and make sure we are working with the right version.
% cd ~/tdroid/tdroid-4.1.1_r6
% repo sync
% repo forall dalvik libcore frameworks/base frameworks/native system/vold system/core device/samsung/crespo device/samsung/tuna \
packages/apps/TaintDroidNotify -c 'git checkout -b taintdroid-4.1.1_r6 --track github/taintdroid-4.1.1_r6 && git pull'
Step 3: Get proprietary binaries
Both the Nexus S and Galaxy Nexus require proprietary binaries not included in the AOSP release. Download the correct version of these files for your device: Nexus S, Nexus S 4G, Galaxy Nexus (GSM/HSPA+), or Galaxy Nexus (Verizon). Then extract the files in your source directory.
Step 3a (for Nexus S):
% cd ~/tdroid/tdroid-4.1.1_r6
% wget https://dl.google.com/dl/android/aosp/akm-crespo-jro03r-f3ebfd11.tgz
% tar -zxvf akm-crespo-jro03r-f3ebfd11.tgz
% ./extract-akm-crespo.sh # (view the license and then type "I ACCEPT")
...
% wget https://dl.google.com/dl/android/aosp/broadcom-crespo-jro03r-66056a98.tgz
% tar -zxvf broadcom-crespo-jro03r-66056a98.tgz
% ./extract-broadcom-crespo.sh # (view the license and then type "I ACCEPT")
...
% wget https://dl.google.com/dl/android/aosp/imgtec-crespo-jro03r-3d5b7fdf.tgz
% tar -zxvf imgtec-crespo-jro03r-3d5b7fdf.tgz
% ./extract-imgtec-crespo.sh # (view the license and then type "I ACCEPT")
...
% wget https://dl.google.com/dl/android/aosp/nxp-crespo-jro03r-09e29a1a.tgz
% tar -zxvf nxp-crespo-jro03r-09e29a1a.tgz
% ./extract-nxp-crespo.sh # (view the license and then type "I ACCEPT")
...
% wget https://dl.google.com/dl/android/aosp/samsung-crespo-jro03r-b1655da2.tgz
% tar -zxvf samsung-crespo-jro03r-b1655da2.tgz
% ./extract-samsung-crespo.sh # (view the license and then type "I ACCEPT")
...
% wget https://dl.google.com/dl/android/aosp/widevine-crespo-jro03r-449f921c.tgz
% tar -zxvf widevine-crespo-jro03r-449f921c.tgz
% ./extract-widevine-crespo.sh # (view the license and then type "I ACCEPT")
Step 3b (for Galaxy Nexus (GSM/HSPA+)):
% cd ~/tdroid/tdroid-4.1.1_r6
% wget https://dl.google.com/dl/android/aosp/broadcom-maguro-jro03r-e25b131d.tgz
% tar -zxvf broadcom-maguro-jro03r-e25b131d.tgz
% ./extract-broadcom-maguro.sh # (view the license and then type "I ACCEPT")
...
% wget https://dl.google.com/dl/android/aosp/imgtec-maguro-jro03r-c7f638f1.tgz
% tar -zxvf imgtec-maguro-jro03r-c7f638f1.tgz
% ./extract-imgtec-maguro.sh # (view the license and then type "I ACCEPT")
...
% wget https://dl.google.com/dl/android/aosp/invensense-maguro-jro03r-1b803782.tgz
% tar -zxvf invensense-maguro-jro03r-1b803782.tgz
% ./extract-invensense-maguro.sh # (view the license and then type "I ACCEPT")
...
% wget https://dl.google.com/dl/android/aosp/samsung-maguro-jro03r-2cd099ee.tgz
% tar -zxvf samsung-maguro-jro03r-2cd099ee.tgz
% ./extract-samsung-maguro.sh # (view the license and then type "I ACCEPT")
Step 3c (for Nexus S 4G):
% cd ~/tdroid/tdroid-4.1.1_r6
% wget https://dl.google.com/dl/android/aosp/akm-crespo4g-jro03r-68feb96f.tgz
% tar -zxvf akm-crespo4g-jro03r-68feb96f.tgz
% ./extract-akm-crespo4g.sh # (view the license and then type "I ACCEPT")
...
% wget https://dl.google.com/dl/android/aosp/broadcom-crespo4g-jro03r-3268837f.tgz
% tar -zxvf broadcom-crespo4g-jro03r-3268837f.tgz
% ./extract-broadcom-crespo4g.sh # (view the license and then type "I ACCEPT")
...
% wget https://dl.google.com/dl/android/aosp/imgtec-crespo4g-jro03r-b0114517.tgz
% tar -zxvf imgtec-crespo4g-jro03r-b0114517.tgz
% ./extract-imgtec-crespo4g.sh # (view the license and then type "I ACCEPT")
...
% wget https://dl.google.com/dl/android/aosp/nxp-crespo4g-jro03r-4fe8447c.tgz
% tar -zxvf nxp-crespo4g-jro03r-4fe8447c.tgz
% ./extract-nxp-crespo4g.sh # (view the license and then type "I ACCEPT")
...
% wget https://dl.google.com/dl/android/aosp/samsung-crespo4g-jro03r-839e8d9c.tgz
% tar -zxvf samsung-crespo4g-jro03r-839e8d9c.tgz
% ./extract-samsung-crespo4g.sh # (view the license and then type "I ACCEPT")
...
% wget https://dl.google.com/dl/android/aosp/widevine-crespo4g-jro03r-06313185.tgz
% tar -zxvf widevine-crespo4g-jro03r-06313185.tgz
% ./extract-widevine-crespo4g.sh # (view the license and then type "I ACCEPT")
Step 3d (for Galaxy Nexus (Verizon)):
% cd ~/tdroid/tdroid-4.1.1_r6
% wget https://dl.google.com/dl/android/aosp/broadcom-toro-jro03r-1bf94b7c.tgz
% tar -zxvf broadcom-toro-jro03r-1bf94b7c.tgz
% ./extract-broadcom-toro.sh # (view the license and then type "I ACCEPT")
...
% wget https://dl.google.com/dl/android/aosp/imgtec-toro-jro03r-3cb69577.tgz
% tar -zxvf imgtec-toro-jro03r-3cb69577.tgz
% ./extract-imgtec-toro.sh # (view the license and then type "I ACCEPT")
...
% wget https://dl.google.com/dl/android/aosp/invensense-toro-jro03r-8f1588ba.tgz
% tar -zxvf invensense-toro-jro03r-8f1588ba.tgz
% ./extract-invensense-toro.sh # (view the license and then type "I ACCEPT")
...
% wget https://dl.google.com/dl/android/aosp/samsung-toro-jro03r-c5fc800d.tgz
% tar -zxvf samsung-toro-jro03r-c5fc800d.tgz
% ./extract-samsung-toro.sh # (view the license and then type "I ACCEPT")
Step 4: Build TaintDroid
First, we need to create a buildspec.mk file and define some variables so that TaintDroid will build properly. There are various options that control different optimizations and logging inside of TaintDroid. The following contents should be sufficient unless you care to begin developing TaintDroid. Note that in the below configuration.
% cd ~/tdroid/tdroid-4.1.1_r6
% edit/create buildspec.mk
# Enable core taint tracking logic (always add this)
WITH_TAINT_TRACKING := true
# Enable taint tracking for ODEX files (always add this)
WITH_TAINT_ODEX := true
# Enable taint tracking in the "fast" (aka ASM) interpreter (recommended)
WITH_TAINT_FAST := true
# Enable additional output for tracking JNI usage (not recommended)
#TAINT_JNI_LOG := true
# Enable byte-granularity tracking for IPC parcels
#WITH_TAINT_BYTE_PARCEL := true
Now we can build TaintDroid. For the "lunch" command, replace <target> with the correct value for your device: full_crespo-eng for Nexus S, full_crespo4g-eng for Nexus S 4G, full_maguro-eng for Galaxy Nexus (GSM/HSPA+), full_toro-eng for Galaxy Nexus (Verizon), or full-eng for the Android emulator.
% . build/envsetup.sh
% lunch <target> # (replace <target> with correct value for your device)
% make clean
% make -j4
Step 5: Flash the device
In order to flash new images, the phone must be connected to the development PC via USB and booted in fastboot mode. Start with the phone powered down, then hold down the "volume up" button (Nexus S) or both "volume up" and "volume down" buttons (Galaxy Nexus) and press the power button. If you have problems using fastboot to flash your device, please refer to the documentation at source.android.com.
If you have not already unlocked your bootloader, first issue the following command to unlock the bootloader:
% fastboot oem unlock
Then, follow the on-screen instructions on the phone to unlock the bootloader. Please note that this will void your warranty.
Before flashing images to your device, we reiterate our previous recommendation: It is strongly recommended that you use the nandroid tool provided in a custom recovery firmware such as ClockWorkMod to backup your current system before flashing new images to your device.
Next, flash the images that we have built. Replace <device> with the correct value for your device: crespo for Nexus S, crespo4g for Nexus S 4G, maguro for Galaxy Nexus (GSM/HSPA+), or toro for Galaxy Nexus (Verizon).
% cd out/target/product/<device> # (replace <device> with correct value for your device)
% fastboot flash boot boot.img
% fastboot flash system system.img
% fastboot flash userdata userdata.img
Step 6 (optional): Install Google apps
Due to licensing restrictions, we cannot distribute proprietary Google applications such as Gmail or the Android Market with the TaintDroid build. If you want to use these apps, you must install them separately from another web site. Installing these apps is optional; they are not required to use TaintDroid.
First, download the Google apps installer from a site such as CyanogenMod and save it on your SDcard.
http://einprogress.io/static/android/cm/gapps/gapps-jb-20120726-signed.zip
Next, flash your device with a custom recovery firmware which provides the ability to install .zip updates from an SDcard, for example ClockWorkMod.
Then boot the recovery firmware on the device by selecting "RECOVERY" from the boot menu, and install the Google apps by selecting "install zip from sdcard" then "choose zip from sdcard" then gapps-jb-20120726-signed.zip.
Step 7: Format the SDcard as ext4 (Nexus S only)
On the Nexus S, the SDcard partition needs to be formatted as ext4 for TaintDroid to track information across files stored to it. Connect the phone to a Linux computer and mount the SDcard by clicking the USB storage notification. Determine the /dev entry for the SDcard (/dev/sdb in our example, but may be different in your case). Use the mkfs.ext4 command to make the file system. The TaintDroid phone will automatically recognize the SDcard formatted as ext4. However, a Windows or Mac computer will not be able to read the SDcard contents.
For example, if the SDcard is attached as /dev/sdb:
% sudo umount /dev/sdb
% sudo mkfs.ext4 /dev/sdb
Step 8: Obtain a kernel with YAFFS2 XATTR support (emulator only)
A custom kernel with XATTR support for the YAFFS2 filesystem is needed for file taint propagation in the emulator. Download the prebuilt kernel:
% cd ~
% wget http://www.appanalysis.org/files/kernel-goldfish-xattr-2.6.29
To boot the emulator with the custom kernel:
% cd ~
% emulator -kernel kernel-goldfish-xattr-2.6.29