Setting Up A Compile Environment

Setting Up A Compile Environment

You must have a 64-bit environment.
A Linux computer should have 8 GB RAM or more, otherwise build errors may occur.

Ubuntu 16.04

These instructions should work for other version of Ubuntu and most other Debian-based systems.

Install build packages
Open a terminal (ctrl + alt + t). First install the necessary packages; copy paste the code below and hit enter.

$ sudo apt-get update && sudo apt-get install git ccache automake lzop bison gperf build-essential zip curl zlib1g-dev zlib1g-dev:i386 g++-multilib python-networkx libxml2-utils bzip2 libbz2-dev libbz2-1.0 libghc-bzlib-dev squashfs-tools pngcrush schedtool dpkg-dev liblz4-tool make optipng maven bc pngquant imagemagick yasm libssl-dev

Check your java version (it must be 1.8)

$ javac -version

If it is 1.7, you MUST change it to 1.8

$ sudo apt-get install openjdk-8-jdk

Get the MoKee Open Source code (MK71.2 base on Android 7.1.2)
~/mokee will be our build directory.

$ mkdir -p ~/bin
$ mkdir -p ~/mokee

$ curl > ~/bin/repo
$ chmod a+x ~/bin/repo

Add bin to PATH

$ echo “export PATH=~/bin:$PATH” >> ~/.bashrc

Configure git:

git config --global "[email protected]"
git config --global “Your Name”

Move to build directory and sync the source code:

cd ~/mokee
repo init -u -b mkn-mr1
repo sync -j4 -f --no-clone-bundle

(If the repo command is still not available, exit the terminal and start a new one so that your new PATH is registered.)
Let’s configure ccache too. It will reduce the build time to 40% after first build

$ echo “export USE_CCACHE=1” >> ~/.bashrc
$ ~/mokee/prebuilts/misc/linux-x86/ccache/ccache -M 50G

25G means it will use upto 25 gb of disk space for ccaching. Atleast 10 gb is recommended. But if you want to compile for more devices, use more space for ccache.


If you really need openjdk 7 sometimes, using following commands to install

$ sudo add-apt-repository ppa:openjdk-r/ppa  
$ sudo apt-get update   
$ sudo apt-get install openjdk-7-jdk  

and you can change default jdk version by

$ sudo update-alternatives --config java
$ sudo update-alternatives --config javac