Building a ROM for Android on Ubuntu 14.04 in Virtualbox 1. Introduction a) Read AOSP Tour from "Embedded Android" Book b) Created Ubuntu 14.04 Virtual Machine with 2 CPUs, 5GB RAM and 200GB dynamic allocation virtual disk. c) Java was not installed in Ubuntu 14.04. d) Followed the instructions from https://source.android.com/source/index.html e) The source code was downloaded and did not use the komban's version f) The time taken to build was easily more than 7 hours ( started the build at around 10 AM and the process was still going on by 4.30 PM - did not measure after that) g) The disk usage was around 64 GB for downloading and building AOSP. 2. Setting up Environment: JAVA SETUP a) Download Oracle Java6 JDK and JRE from http://download.oracle.com b) Commands to install Java # mkdir /usr/local/java # cd /usr/local/java/ # mv /home/jevitha/downloads/jre-6u45-linux-x64.bin. # chmod +x jre-6u45-linux-x64.bin # ls -l jre-6u45-linux-x64.bin #./jre-6u45-linux-x64.bin # ls -l jre1.6.0_45/ # mv /home/jevitha/downloads/jdk-6u45-linux-x64.bin. # chmod +x jdk-6u45-linux-x64.bin #./jdk-6u45-linux-x64.bin c) Setting up JAVA in the path Add these in ~/.bashrc JAVA_HOME=/usr/local/java/jdk1.6.0_45 JRE_HOME=$JAVA_HOME/jre PATH=$PATH:$JAVA_HOME/bin:$JRE_HOME/bin export JAVA_HOME export JRE_HOME export PATH d) Test whether Java is installed properly by issuing java and javac commands. jevitha@jevitha-virtualbox:~$ java -version java version "1.6.0_45" Java(TM) SE Runtime Environment (build 1.6.0_45-b06) Java HotSpot(TM) 64-Bit Server VM (build 20.45-b01, mixed mode) jevitha@jevitha-virtualbox:~$ javac -version javac 1.6.0_45 jevitha@jevitha-virtualbox:~$
ENVIRONMENT DETAILS jevitha@jevitha-virtualbox:~$ gcc -v Using built-in specs.... gcc version 4.8.2 (Ubuntu 4.8.2-19ubuntu1) jevitha@jevitha-virtualbox:~$ make -version GNU Make 3.81... 3. Setting up the required libraries Installed the libraries mentioned for ubuntu 14.04 as mentioned on https://source.android.com/source/initializing.html #sudo apt-get install bison g++-multilib git gperf libxml2-utils 4. Configuring USB Access a) As per the instructions on the https://source.android.com/source/initializing.html Create a file /etc/udev/rules.d/51-android.rules & copied the following lines into the file after changing the OWNER filed to the username on my machine. # adb protocol on passion (Nexus One) SUBSYSTEM=="usb", ATTR{idVendor}=="18d1", ATTR{idProduct}=="4e12", MODE="0600", OWNER="jevitha" # fastboot protocol on passion (Nexus One) SUBSYSTEM=="usb", ATTR{idVendor}=="0bb4", ATTR{idProduct}=="0fff", MODE="0600", OWNER="jevitha" # adb protocol on crespo/crespo4g (Nexus S) SUBSYSTEM=="usb", ATTR{idVendor}=="18d1", ATTR{idProduct}=="4e22", MODE="0600", OWNER="jevitha" # fastboot protocol on crespo/crespo4g (Nexus S) SUBSYSTEM=="usb", ATTR{idVendor}=="18d1", ATTR{idProduct}=="4e20", MODE="0600", OWNER="jevitha" # adb protocol on stingray/wingray (Xoom) SUBSYSTEM=="usb", ATTR{idVendor}=="22b8", ATTR{idProduct}=="70a9", MODE="0600", OWNER="jevitha" # fastboot protocol on stingray/wingray (Xoom) SUBSYSTEM=="usb", ATTR{idVendor}=="18d1", ATTR{idProduct}=="708c", MODE="0600", OWNER="jevitha" # adb protocol on maguro/toro (Galaxy Nexus) SUBSYSTEM=="usb", ATTR{idVendor}=="04e8", ATTR{idProduct}=="6860", MODE="0600", OWNER="jevitha" # fastboot protocol on maguro/toro (Galaxy Nexus) SUBSYSTEM=="usb", ATTR{idVendor}=="18d1", ATTR{idProduct}=="4e30", MODE="0600", OWNER="jevitha" # adb protocol on panda (PandaBoard) SUBSYSTEM=="usb", ATTR{idVendor}=="0451", ATTR{idProduct}=="d101", MODE="0600", OWNER="jevitha" # adb protocol on panda (PandaBoard ES) SUBSYSTEM=="usb", ATTR{idVendor}=="18d1", ATTR{idProduct}=="d002", MODE="0600", OWNER="jevitha" # fastboot protocol on panda (PandaBoard)
SUBSYSTEM=="usb", ATTR{idVendor}=="0451", ATTR{idProduct}=="d022", MODE="0600", OWNER="jevitha" # usbboot protocol on panda (PandaBoard) SUBSYSTEM=="usb", ATTR{idVendor}=="0451", ATTR{idProduct}=="d00f", MODE="0600", OWNER="jevitha" # usbboot protocol on panda (PandaBoard ES) SUBSYSTEM=="usb", ATTR{idVendor}=="0451", ATTR{idProduct}=="d010", MODE="0600", OWNER="jevitha" # adb protocol on grouper/tilapia (Nexus 7) SUBSYSTEM=="usb", ATTR{idVendor}=="18d1", ATTR{idProduct}=="4e42", MODE="0600", OWNER="jevitha" # fastboot protocol on grouper/tilapia (Nexus 7) SUBSYSTEM=="usb", ATTR{idVendor}=="18d1", ATTR{idProduct}=="4e40", MODE="0600", OWNER="jevitha" # adb protocol on manta (Nexus 10) SUBSYSTEM=="usb", ATTR{idVendor}=="18d1", ATTR{idProduct}=="4ee2", MODE="0600", OWNER="jevitha" # fastboot protocol on manta (Nexus 10) SUBSYSTEM=="usb", ATTR{idVendor}=="18d1", ATTR{idProduct}=="4ee0", MODE="0600", OWNER="jevitha" 5. Did not setup ccache Since was mentioned as optional setup 6. Install Repo tool 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 sha1sum on repo matched For version 1.21, the SHA-1 checksum for repo is b8bd1804f432ecf1bab730949c82b93b0fc5fede 7. Downloading sources $mkdir android $ cd android Run repo init to bring down the latest version of Repo with all its most recent bug fixes. $ repo init -u https://android.googlesource.com/platform/manifest Figured out the build number from https://source.android.com/source/build-numbers.html, under SOURCE CODE TAGS AND BUILDS section. To check out a branch other than "master", specify it with -b: $ repo init -u https://android.googlesource.com/platform/manifest -b android-4.4.4_r1 $ repo sync 8. Initialize Build environment Initialize the environment with the envsetup.sh script $ source build/envsetup.sh or
root@jevitha-virtualbox:/usr/local/java/android#. build/envsetup.sh 9. Choose a Target Choose which target to build with lunch. The exact configuration can be passed as an argument, e.g. root@jevitha-virtualbox:/usr/local/java/android# lunch You're building on Linux Lunch menu... pick a combo: 1. aosp_arm-eng 2. aosp_x86-eng 3. aosp_mips-eng 4. vbox_x86-eng 5. mini_armv7a_neon-userdebug 6. mini_mips-userdebug 7. mini_x86-userdebug 8. aosp_grouper-userdebug 9. aosp_flo-userdebug 10. aosp_deb-userdebug 11. aosp_tilapia-userdebug 12. aosp_manta-userdebug 13. aosp_hammerhead-userdebug 14. aosp_mako-userdebug Which would you like? [aosp_arm-eng] Press Enter to choose this to build for the ARM emulator ============================================ PLATFORM_VERSION_CODENAME=REL PLATFORM_VERSION=4.4.4 TARGET_PRODUCT=aosp_arm TARGET_BUILD_VARIANT=eng TARGET_BUILD_TYPE=release TARGET_BUILD_APPS= TARGET_ARCH=arm TARGET_ARCH_VARIANT=armv7-a TARGET_CPU_VARIANT=generic HOST_ARCH=x86 HOST_OS=linux HOST_OS_EXTRA=Linux-3.13.0-32-generic-x86_64-with-Ubuntu-14.04-trusty
HOST_BUILD_TYPE=release BUILD_ID=KTU84P OUT_DIR=out... 10. Start the build root@jevitha-virtualbox:/usr/local/java/android# make -j16... error --- install flex... There were multiple errors at this time to install some missing packages: # apt-get install flex... The following NEW packages will be installed: flex libfl-dev... # apt-get install build-essential... The following NEW packages will be installed: build-essential dpkg-dev libalgorithm-diff-perl libalgorithm-diff-xs-perl libalgorithm-merge-perl... The following NEW packages will be installed: build-essential dpkg-dev libalgorithm-diff-perl libalgorithm-diff-xs-perl libalgorithm-merge-perl... root@jevitha-virtualbox:/usr/local/java/android# make -j16... /usr/local/java/android/prebuilts/gcc/linux-x86/host/i686-linux-glibc2.7-4.6/bin/../lib/gcc/i686- linux/4.6.x-google/../../../../i686-linux/bin/as: error while loading shared libraries: libz.so.1: cannot open shared object file: No such file or directory make: *** [out/host/linux-x86/obj/static_libraries/libutils_intermediates/basichashtable.o] Error 1... error while loading shared libraries: libz.so.1 Quick lookup on google mentioned the following step to fix the libz.so.1 error: # apt-get install -y libc6:i386 libgcc1:i386 libstdc++6:i386 libz1:i386 # lunch # make -j16 Build success.
#emulator --- to load the emulator with the built image