Welcome to BBTECH Lab

Technical Note for Developing Embedded Media Devices, Set-Top-Boxes, Broadband TV, DVR, etc.

[AndroidTV][2]Android Emulator Setup and Build Environment

[AndroidTV][2]Android Emulator Setup and Build Environment

I. Setting up the Host Environment

1.1 Host requirement

RequirementRemarks
Linux64bit Ubuntu 16.04.4 LTS
Virtual MachineOracle Virtual Box 4.3.18 or higher
Free HDD SpaceMinimum 100GB Free Memory

1.2 Install independent package

refer to https://source.android.com/setup/build/initializing

$ sudo apt-get update
$ sudo apt-get install build-essential gettext bison libfile-slurp-perl gawk libncurses-dev autoconf flex doxygen libtool automake libpcre3-dev zlib1g-dev libbz2-dev subversion minicom putty libssl-dev rpm python-pexpect python-svn python-argparse vim tofrodos meld dos2unix cmake uuid-dev ruby transfig libglib2.0-dev xutils-dev lynx-cur gperf autopoint python-dulwich python-dev curl vim diffstat texinfo chrpath openjdk-8-jdk
$ sudo apt-get install sed wget cvs subversion git-core coreutils unzip texi2html texinfo libsdl1.2-dev docbook-utils gawk python-pysqlite2 diffstat help2man make gcc build-essential g++ desktop-file-utils chrpath libgl1-mesa-dev libglu1-mesa-dev mercurial autoconf automake groff

II. Downloading the Source

refer to https://source.android.com/setup/build/downloading

2.1 Install Repo

$ mkdir ~/bin
$ PATH=~/bin:$PATH
$ curl https://storage.googleapis.com/git-repo-downloads/repo > ~/bin/repo
$ chmod a+x ~/bin/repo

2.2 Configure bash as default command interpreter for shell scripts

$ sudo dpkg-reconfigure dash

Select “No”
To choose bash, when the prompt asks if you want to use dash as the default system shell – select “No”

2.3 Configure GIT

Upgrade your Git version to 1.8.x or higher

$ git config --global user.name "Your Name" 
$ git config --global user.email "you@example.com"

2.4 Downloading the Source

$ mkdir -p android
$ repo init
$ repo sync

bamboo@bbtechlab:~/work/androidTV/android$ tree -L 1 ./
./
├── Android.bp -> build/soong/root.bp
├── art
├── bionic
├── bootable
├── bootstrap.bash -> build/soong/bootstrap.bash
├── build
├── cts
├── dalvik
├── developers
├── development
├── device
├── docs
├── external
├── frameworks
├── hardware
├── kernel
├── libcore
├── libnativehelper
├── Makefile
├── out
├── packages
├── pdk
├── platform_testing
├── prebuilts
├── sdk
├── system
├── test
├── toolchain
└── tools
26 directories, 3 files
bamboo@bbtechlab:~/work/androidTV/android$

2.5 Compiling

Refer to https://source.android.com/setup/build/building

$ make clobber  # delete the existing output of any previous build

$ source build/envsetup.sh # Initialize the environment with the envsetup.sh script

$ lunch aosp_arm-eng       # Choose which target to build with lunch. The exact configuration can be passed as an argument. For example, the following command refers to a complete build for the emulator, with all debugging enabled:

$ make -j8  # Compiling

The output locate in

bamboo@bbtechlab:~/work/androidTV/android$ tree -L 1 out/
out/
├── Android.mk
├── build-aosp_arm.ninja
├── build_date.txt
├── build_number.txt
├── build.trace.1.gz
├── build.trace.2.gz
├── build.trace.gz
├── casecheck.txt
├── CaseCheck.txt
├── CleanSpec.mk
├── combined-aosp_arm.ninja
├── env-aosp_arm.sh
├── host
├── microfactory_Linux
├── ninja-aosp_arm.sh
├── ninja_build
├── soong
├── soong.1.log
├── soong.2.log
├── soong.log
├── soong_ui
├── target
└── versions_checked.mk

3 directories, 20 files
bamboo@bbtechlab:~/work/androidTV/android$

III. Bring-up Android in emulator

The emulator is added to your path automatically by the build process. To run the emulator, type:

$ emulator

IV. Reference

[1], https://source.android.com/setup/build/downloading

[2], https://source.android.com/setup/build/initializing

bbtechlab