Android

Build your own

My motivation 2017-04 for building my own "Android" was, there is no official build for the Sony Z1 from LinegeOS, the only available inofficial build is from 2016-12 and the last offcial build from CynogenMod is from 2016-10.

First you need the "repo" tool from google, which is a xk line python code wrapper for single git commands. You should store it in directory which is in PATH variable. e.b. ~/bin. Storing it in another place and calling python $yourpathtotherepofile/repo does not work, because some scripts call it too.

wget http://commondatastorage.googleapis.com/git-repo-downloads/repo

Decide where to store the data (~53GB for cm-14.1) and change dir to this new empty directory. Initialize the repo and sync. How long you must wait for the sync depends on your internet connection speed.

repo init -u git://github.com/LineageOS/android.git -b cm-14.1
repo sync
Maybe you will now copy or backup these unmodified Data.

Prepare code. You need to know your codename of your phone! Try wikipedia or the lineageos wiki if you don't. e.g. mako for the nexus4. You can use this to try if everything ist working with an official supported device.

source build/envsetup.sh
breakfast $codename

Extract firmwares. Connect your phone and allow adb debug and root for adb in your current running android.

export codename=mako # codename of your phone
cd device/$vendor/$codename
./extract-files.sh
adb kill-server
cd ../../../
You will find the files in vendor/$vendor/$codename/proprietary

Now you can try to build it. You need at least 10GiB Ram (8GiB with the same size for swap will work to)

unset _JAVA_OPTIONS
export USE_CCACHE=1
prebuilts/misc/linux-x86/ccache/ccache -M 50G
source build/envsetup.sh
croot
export JACK_SERVER_VM_ARGUMENTS="-Dfile.encoding=UTF-8 -XX:+TieredCompilation -Xmx4g"
prebuilts/sdk/tools/jack-admin start-server
brunch $codename
pitfalls