Build and Evaluate Android TV on HiKey

The objective of this page is to share the instructions to build and evaluate Android TV on's open HiKey development platform.

What has been done so far

* Based on Linaro's RLCR release, we have added few patches to enable Android TV features for Hikey.

* The source manifest also pulls Sample Inputs project.

* The sample inputs projects and it's dependencies are built using gradle scripts.

* The pre-built snapshot images can be pulled from Note: For bootloader firmware, please use

* These images work on Lemaker's version of Hikey platform.

HOW TO Establish build environment

Kindly refer to Google provided instructions to setup the build environment for Android

Before doing repo init or repo sync kindly install few other host dependencies by executing the below command.

sudo apt-get install git-core gnupg flex bison gperf build-essential zip curl zlib1g-dev g++-multilib libc6-dev-i386 lib32ncurses5-dev x11proto-core-dev libx11-dev lib32z-dev ccache libgl1-mesa-dev libxml2-utils xsltproc unzip vim-common python-parted python-yaml wget uuid-dev python-mako u-boot-tools bc acpica-tools python-wand python-crypto mtools liblz4-tool

HOW TO Download the sources

Instructions to clone the sources are :

repo init -u -b android-7.1.1_r28 -g "default,-non-default,-device,hikey,fugu"
cd .repo
git clone -b linaro-nougat-tv local_manifests
cd -
repo sync -j16

WARNING: If you run repo sync again at any time in the future to update all the repos, by default all the patches above would be discarded, so you'll have reapply them again before rebuilding!

tar -xvf vendor.tar.bz2


NOTE : The settings app crashes with default Android launcher when Android is configured for TV.

To get a working settings app, we recommend you to use LeanbackLauncher. The steps are as given below:

From this link download the latest launcher for TV from Google.

Example : Download

In Android source directory

tar -xzvf google-fugu-lrx21m-b6038c1e.tgz

The LeanbackLauncher will be built as part of Android and Android would boot with this launcher.

HOW TO Build the sources

source build/
lunch hikey-userdebug

** Build for 8GB flash Hikey


** Build for 4GB flash Hikey

source build/

[Build Live Tv Launcher]

tapas LiveTv arm64
make LiveTv
cp -r out/target/product/generic_arm64/system/priv-app/LiveTv/ out/target/product/hikey/system/priv-app/
mkdir -p apps/
cd apps/

NOTE : You should have Android SDK tools installed in your system, if not then please follow these steps one time, need not repeat these for every build :

# Look for the latest version of the tools here and give the corresponding name of the zip file for wget
(while :; do   echo 'y';   sleep 2; done) | tools/android update sdk --no-ui
mkdir -p /home/<your user name>/.android/
echo "count=0" > /home/<your user name>/.android/repositories.cfg

# List all build tools and install the required ones
./tools/android list sdk --all
./tools/android update sdk -u -a -t 47
./tools/android update sdk -u -a -t 15
./tools/android update sdk -u -a -t 8
./tools/android update sdk -u -a -t 6
./tools/android update sdk -u -a -t 7

If you have SDK installed previously then discard skip the steps above and continue as below

export ANDROID_HOME=<path to sdk>
echo "count=0" > $HOME/.android/repositories.cfg
rm -rf ExoPlayer androidtv-sample-inputs

Building apps and dependencies


git clone
cd androidtv-sample-inputs/
sed -i "s/23.0.3/25.0.2/g" app/build.gradle library/build.gradle
./gradlew assembleDebug
cp app/build/outputs/apk/app-debug.apk ../../out/target/product/hikey/data/app/
cd -


git clone
cd ExoPlayer
sed -i "s/23.0.3/25.0.2/g" build.gradle
./gradlew assembleDebug
cp ./demo/buildout/outputs/apk/demo-withExtensions-debug.apk  ../../out/target/product/hikey/data/app/
cd -

Tested with:

1b66908f7d79b6891d8d99705470797640457e72 (r2.6.0 + 1 commit)

2b20780482a9c6b07416bcbf4de829532859d10a (r2.6.1)

How to enable OPTEE support

1. Use Pre-built UEFI firmware: Download fip.bin here

Replace the firmware by following commend:

$ fastboot flash fastboot fip.bin

2. Build UEFI firmware manually:

$ cd device/linaro/hikey/bootloader/
$ cd -

find the fip.bin at out/dist/

Preparing Images

# Compress images

cd out/target/product/hikey
../../../host/linux-x86/bin/make_ext4fs -s -T -1 -S root/file_contexts -L data -l 5588893184 -a data userdata.img data
../../../host/linux-x86/bin/make_ext4fs -s -T -1 -S root/file_contexts.bin -L system -l 1610612736 -a system system.img system system

Build UEFI bootloader with OP-TEE

cd device/linaro/hikey/bootloader

Enable adb over usb

Boot the device. On serial console:

setprop sys.usb.configfs 1
stop adbd
start adbd

Submit Code changes

* Developers working on AOSP TV will have to implement the features and push patches using Gerrit. Details on how to use Gerrit is here,

* To post patches against Android's existing projects - Submit the patch to gerrit for review and include the patch in hikey-tv patchset:

* The file "hikey-tv" should contain all the patches related to hikey-tv configuration. We can also have a tv-patchsets file which will contain Android TV specific patches that one wishes to include.

* To post patches that introduces an all new project then ask Systems team to create a project repository and then post the patches against this repository.

Q&A & Notes

1. Q: I cannot pass the WV CDM Security L1 check and always falling back to L3 when using Exoplayer.

A: Check the /dev/tee* device nodes persission.


# chmod 777 /dev/tee* 

LHG/Build-AndroidTV-For-Hikey (last modified 2019-02-15 02:54:39)