Build Lineage 15

Published: Updated:
Published: Updated:

Here is the story of how I started upgrading Android on my Nvidia Shield tablet because one day I saw a popup in the app, where I read ebooks from my public library, that soon they will drop support of Android 7.

Setup Docker

So I open VirtualBox and blow off dust from my Ubuntu 18 virtual machine. "Blowing" means I run apt update && apt upgrade. It's also possible to do everything in a docker container:

docker run -it --name lineage-build ubuntu:18.04 bash
# install all stuff in the container
# ...
# use it again next day
docker start -i lineage-build
# or save as image (very fat image though)
docker container ls -a -s # check size (72GB after git clone, 126GB after build)
docker commit lineage-build lineagos:15.1
# in case you run `adb` from the docker mount `dev`, open ports
docker run --tty --detached --privileged --volume /dev/bus/usb:/dev/bus/usb --publish-all --name lineage-build-2 lineagos:15.1
docker ps -a
docker exec --tty --interactive d886b12741a8 bash

Then prepare docker a bit

apt update && apt install sudo
update-alternatives --install /usr/bin/python python /usr/bin/python3.6 1 # we will switch to Python 2 later
git config --global ""
git config --global "Nikolay Neupokoev"
sed "s/TLSv1, TLSv1.1, //" -i /etc/java-8-openjdk/security/
export USER=nikolay # stupid script from Jack server needs it

Then we follow the build instructions. The excerpt.

Install stuff

sudo apt install bc bison build-essential ccache curl flex g++-multilib gcc-multilib git git-lfs gnupg gperf imagemagick \
  lib32ncurses5-dev lib32readline-dev lib32z1-dev libelf-dev liblz4-tool libncurses5 libncurses5-dev \
  libsdl1.2-dev libssl-dev libxml2 libxml2-utils lzop pngcrush rsync \
  schedtool squashfs-tools xsltproc \
  zip zlib1g-dev \
  libwxgtk3.0-dev \
  openjdk-8-jdk \
  python2.7 \

curl -L -o
unzip -d ~

mkdir -p  ~/.local/bin
curl > ~/.local/bin/repo
chmod a+x ~/.local/bin/repo

Set environment variables to make it work and with some build tweaks

export PATH=/root/platform-tools:/root/.local/bin:$PATH

export USE_CCACHE=1
export CCACHE_EXEC=/usr/bin/ccache
ccache -M 50G
ccache -o compression=true
export ANDROID_JACK_VM_ARGS="-Dfile.encoding=UTF-8 -XX:+TieredCompilation -Xmx4G"
export ANDROID_JACK_EXTRA_ARGS="--verbose debug --sanity-checks on -D sched.runner=single-threaded"

Get the repo. Note: you have to use local directories owned by your user and not ones mounted into virtual machine from the host that usually have root:vboxsf ownership.

mkdir /lineage
cd /lineage
repo init -u -b lineage-15.1 --git-lfs
repo sync

# switch to Python 2
update-alternatives --install /usr/bin/python python /usr/bin/python2.7 2
source build/
breakfast shieldtablet

# be careful with this step, it's possible to approach it with 3 different sides
cd /lineage/device/nvidia/shieldtablet

# change directory to build root
# start multi-threaded make job for "shieldtablet" target
brunch shieldtablet

Hint: taskset -c 0-3 bash to restrict a shell to only 4 cores (0-3; adjust as you need), then envsetup and brunch.

Extracting proprietary files

Ooooo, this doesn't look good

[44/44] bootstrap /lineage/out/soong/.minibootstrap/
[4/4] /lineage/out/soong/.bootstrap/bin/minibp /lineage/out/soong/.bootstrap/
[878/879] glob vendor/qcom/opensource/interfaces/wifi/supplicant/1.0/Android.bp
[56/56] /lineage/out/soong/.bootstrap/bin/soong_build /lineage/out/soong/
/lineage/out/ is missing, regenerating...
[742/1072] including ./system/sepolicy/ ...
./system/sepolicy/ warning: BOARD_SEPOLICY_VERS not specified, assuming current platform version
[1072/1072] including ./vendor/qcom/opensource/rcs-service/ ...
PRODUCT_COPY_FILES device/nvidia/shield-common/keylayout/Vendor_054c_Product_0268.kl:system/usr/keylayout/Vendor_054c_Product_0268.kl ignored.
[ 99% 1282/1283] glob vendor/qcom/opensource/interfaces/wifi/supplicant/1.0/Android.bp
ninja: error: 'vendor/nvidia/shieldtablet/proprietary/vendor/app/NvShieldTech/NvShieldTech.apk', needed by '/lineage/out/target/product/shieldtablet/obj/APPS/NvShieldTech_intermediates/package.apk', missing and no known rule to make it
22:44:36 ninja failed with: exit status 1

#### failed to build some targets (27 seconds) ####

Which is caused most likely by errors from previous script (

root@d886b12741a8:/lineage/device/nvidia/shieldtablet# ./
No device is online. Waiting for one...
Please connect USB and/or enable USB debugging
Device Found.
Cleaning output directory (./../../../vendor/nvidia/shieldtablet/proprietary)..
Extracting 160 files in ./proprietary-files.txt from adb:
  - /system/etc/hdcpsrm/hdcp1x.srm ..
  - /system/etc/hdcpsrm/hdcp2x.srm ..
  - /system/etc/hdcpsrm/hdcp2xtest.srm ..
  - /system/vendor/bin/downloader ..
    !! file not found in source
  - /system/vendor/bin/glgps_nvidiaTegra2android ..
    !! file not found in source
  - /system/vendor/bin/ ..
    !! file not found in source
  - /system/vendor/bin/icera-switcherd ..
    !! file not found in source
  - /system/vendor/bin/modemnic ..
    !! file not found in source
  - /system/vendor/bin/rm_ts_server ..
    !! file not found in source
  - /system/vendor/bin/ ..
    !! file not found in source
  - /system/vendor/bin/ss_status ..
    !! file not found in source
  - /system/vendor/bin/tlk_daemon ..
    !! file not found in source
  - /system/vendor/bin/ussrd ..
    !! file not found in source

Full output I saved in a gist

I did some investigation. Here is an issue with similar errors. Seems like I've missed one note on the wiki, saying that these files must be taken from a tablet where Lineage OS is already installed.

This step requires to have a device already running the latest LineageOS, based on the branch you wish to build for. If you don’t have access to such device, refer to Extracting proprietary blobs from installable zip.

LineageOS build instructions

So I can retrieve it from installed Lineage OS, or zip file, or proprietary_vendor_nvidia repository (possible mirror or fork on gitlab).

I can see that I downloaded the same files to /lineage/vendor/nvidia/shieldtablet/proprietary/vendor/firmware/ as in shield/firmware/t124 but actually they have different hashes

If you extract blobs from zip (like, then you need to read "Extracting proprietary blobs from block-based OTAs" link. Check out this howto too. And again they will have different hashes

Hierarchy is strange, so I manually moved missing files

mkdir -p /system_dump/system/vendor/app/ConsoleUI
cp -v /proprietary_vendor_nvidia/shield/app/ConsoleUI/ConsoleUI.apk /system_dump/system/vendor/app/ConsoleUI
cp -v /shieldtablet/shieldtablet.real.bak/proprietary/vendor/lib/ /system_dump/system/vendor/lib
cp -v /shieldtablet/shieldtablet.real.bak/proprietary/vendor/lib/libgov* /system_dump/system/vendor/lib
cp -v /shieldtablet/shieldtablet.real.bak/proprietary/vendor/lib/ /system_dump/system/vendor/lib
cp -v /shieldtablet/shieldtablet.real.bak/proprietary/vendor/lib/ /system_dump/system/vendor/lib
cp -v /shieldtablet/shieldtablet.real.bak/proprietary/vendor/lib/ /system_dump/system/vendor/lib

What's missing from zip


What's missing from official ROM


Maybe it's hard to see but files in these lists almost do not overlap, therefore I will use zip and replenish missing files using my ROM.

But here's what I must delete for sure from device/nvidia/shieldtablet/proprietary-files.txt


And then I used the following command that doesn't use adb but just uses files from another folder

./ /system_dump/

Troubleshooting Jack

It was not so easy with Jack, because it's another piece of software that I've never heard of. Yes, those 80 gigabytes of kernel stuff didn't worry me so much as this one.

I've got this error

Launching Jack server java -XX:MaxJavaStackTraceDepth=-1 -Dfile.encoding=UTF-8 -XX:+TieredCompilation -Xmx4G -cp /root/.jack-server/launcher.jar
Jack server failed to (re)start, try 'jack-diagnose' or see Jack server log
SSL error when connecting to the Jack server. Try 'jack-diagnose'

So here's a few helpful commands that help you to tame this beast

jack-admin kill-server
jack-admin start-server

The problem was fixed by enabling deprecated TLS algorithms in Java 8. I added that to my initial Docker commands above.


I build Lineage 16 from source

Rate this page