-
Notifications
You must be signed in to change notification settings - Fork 7
Developer's Guide
This is a developer's guide which helps you to download the NANS source tree and build a system image proper to your target device. Further more, you can modify the project and build your own. Please try and make contributions for the project.
Before you download and build the Android source, ensure your system meets the following requirements:
- Google Google Nexus series smartphone.
- PC with at least 100GB of free disk space for a checkout, 150GB for a single build, and 200GB or more for multiple builds.
- Micro 5-pin USB Cable
- At least one of external displays supports Miracast or HDMI. For HDMI connection, you need SlimPort-to-HDMI adapter
Warning: You may need to backup the phone. Flashing system images will change entire system of the device.
- A Linux or Mac OS system (64-bit). It is also possible to build Android in a virtual machine on unsupported systems such as Windows.
- Java Development Kit 7, which you can download from oracle.com.
- Python 2.6 -- 2.7, which you can download from python.org.
- GNU Make 3.81 -- 3.82, which you can download from gnu.org.
- Git 1.7 or newer. You can find it at git-scm.com.
For more information, visit http://source.android.com/source/requirements.html
You can get information about establishing a build environment from the manual on the official android webpage.
http://source.android.com/source/initializing.html
This is mainly about installing the JDK and other required packages for Linux or Mac OS.
The NANS source tree is located in a Git repository. Here are the repositories of each modified source.
- https://github.com/rubis-lab/NANS_frameworks_base
- https://github.com/rubis-lab/NANS_frameworks_native
- https://github.com/rubis-lab/NANS_hardware_libhardware_legacy
- https://github.com/rubis-lab/NANS_packages_apps_settings
You can download them seperately on your own Android project or you can download whole NANS project with Android as following steps.
Repo is a tool that makes it easier to work with Git in the context of Android.
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:
$ git config --global user.name "Your Name" $ git config --global user.email "you@example.com" -
Downloading the source tree should take several hours due to its size. To download the latest version(master branch) of repository for NANS project:
$ repo init -u https://github.com/rubis-lab/NANS_Project_for_Android $ repo sync
Or to check out a branch other than "master", specify it with -b.
$ repo init -u https://github.com/rubis-lab/NANS_Project_for_Android -b 5.1.1
$ repo sync
For more information, visit http://source.android.com/source/downloading.html
For building system for your target device, additional hardware-related proprietary libraries are needed to run.
You can download official binaries for the supported devices from Google's Nexus driver page. Find out your target device's binaries for the same android version as NANS' version, and download it to your WORKING_DIRECTORY.
e.g. NANS(5.1.1) for Nexus 5 --> Nexus 5 ("hammerhead") binaries for Android 5.1.1
Each set of binaries comes as a self-extracting script in a compressed archive. Uncompress each archive, run the included self-extracting script from the root of the source tree, then confirm that you agree to the terms of the enclosed license agreement. The binaries and their matching makefiles will be installed in the vendor/ hierarchy of the source tree.
The basic sequence of build commands is as follows:
Initialize the environment with the envsetup.sh script.
$ source build/envsetup.sh
or
$ . build/envsetup.sh
Choose which target to build:
$ lunch
Then you will see your target device's code name, for example, 'aosp_hammerhead-userdebug'. Then you can select it.
Note : If you cannot see your target, make sure you installed proprietary binaries appropriately.
Or you can configure passing the code name as an argument.
$ lunch hammerhead
If you want to build a image for Android Virtual Device (AVD), you have to choose 'aosp_arm-eng'. Or you can configure passing the code name as an argument.
$ lunch aosp_arm-eng
Build everything with make.
Building whole Android source tree should take several hours. GNU make can handle parallel tasks with a -jN argument, and it's common to use a number of tasks N that's between 1 and 2 times the number of hardware threads on the computer being used for the build. For example, on a dual-E5520 machine (2 CPUs, 4 cores per CPU, 2 threads per core), the fastest builds are made with commands between make -j16 and make -j32.
$ make -j4
Once you build whole source tree, you can use mm and make snod for building only an individual program or module. For more information, visit http://elinux.org/Android_Build_System#Speeding_up_the_build.
After successful build, you will see image files such as 'system.img', 'boot.img' and 'userdata.img' in WORKING_DIRECTORY/out/tartget/product/TARGET_CODE_NAME/
Reference : http://source.android.com/source/building.html, http://source.android.com/source/running.html
The device should be in fastboot mode which is a mode in the bootloader that can be used to flash the device.
To flash a device, you will need to use fastboot and adb, which should be included in your path after a successful build.
If you don't already have fastboot and adb, you can build them with the regular build system. Use the instructions in Building the System and replace the main make command with:
$ make fastboot adb
Place the device in fastboot mode either manually by holding the appropriate key combination at boot, or from the shell with the device connected to PC:
$ adb reboot bootloader
If it is successful, it shows like below,

It's possible to flash a custom system only if the bootloader allows it, and the bootloader is locked by default. You can unlock the bootloader, but be aware that doing so deletes the user data for privacy reasons (the unlock operation needs to run only once).
With the device in fastboot mode, unlock the bootloader using:
$ fastboot oem unlock
Once the device is in fastboot mode, run:
$ fastboot flashall
Or you can flash individual images:
$ fastboot flash system system.img
$ fastboot flash boot boot.img
$ fastboot flash userdata userdata.img
$ fastboot flash recovery recovery.img
As you flash the images, there will be NANS option in Settings. Enable NANS and Multi-Touch options.
You can use external displays by connecting with SlimPort(HDMI) and/or Miracast.
- For connecting via SlimPort, you can do simply by connecting the cable.
- For Miracast connection, you need to turn on the Wi-Fi, go Settings > Display & lights > Cast screen and then select the wireless display.

Copyright (C) RUBIS Laboratory at Seoul National University