Building userdebug android images for Pixel

Those are the steps I took to build userdebug images for google Pixel on Ubtuntu 16.04. As the original google documentation is so unorganized and difficult to understand I’ve summed up the important parts to get a quick build for any device. I’m quite unsure about the package dependencies and there might be some more packages you need. Let me know if you needed more packages on clean install of Ubuntu.

1. First start with installing necessary packages

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

2. Building android somehow requires some x86 libraries so install them as well

sudo dpkg --add-architecture i386
sudo apt-get update
sudo apt-get install libc6:i386 libncurses5:i386 libstdc++6:i386

3. Download repo client and install it somewhere

mkdir ~/bin
PATH=~/bin:$PATH

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

4. Make source directory and add git information for checkout

mkdir android_dev
cd android_dev

git config --global user.name "Your Name"
git config --global user.email "someaddress@someprovider.com"

5. Download actual source and build environment
Branch names can be found at https://source.android.com/setup/start/build-numbers

repo init -u https://android.googlesource.com/platform/manifest -b android-8.1.0_r28

repo sync

make clobber

6. (OPTIONAL) Download nonfree drivers, if you skip this step vendor.img will not be built.
Matching drivers can be found at https://developers.google.com/android/drivers

wget https://dl.google.com/dl/android/aosp/google_devices-sailfish-opm4.171019.016.b1-839e6b26.tgz
wget https://dl.google.com/dl/android/aosp/qcom-sailfish-opm4.171019.016.b1-3c7f92b3.tgz

tar xvf google_devices-sailfish-opm4.171019.016.b1-839e6b26.tgz
tar xvf qcom-sailfish-opm4.171019.016.b1-3c7f92b3.tgz

./extract-google_devices-sailfish.sh
./extract-qcom-sailfish.sh

7. Prepare build options and make
Available build configurations can be found at https://source.android.com/setup/build/running

source build/envsetup.sh

lunch aosp_sailfish-userdebug

make -j8

Resulting image files can be found at out/target/product/<device_name>

 

Troubleshooting #1. If build fails with “out of heap space” error, execute the commands below and continue make

export JACK_SERVER_VM_ARGUMENTS="-Dfile.encoding=UTF-8 -XX:+TieredCompilation -Xmx4g"
jack-admin kill-server && jack-admin start-server

Leave a Reply

Your email address will not be published. Required fields are marked *