Android Development – Setting up the environment
Often your device comes with a not so optimized stock ROM, and after some usage it gets laggy and slow. Many check on the web and find the solution, others try to build their personal rom on their own.
This is one of the three tutorials I am going to write to explain you, in a comprehensive way, how to build a custom Android ROM for your device.
If you want to build an Android ROM you will need a Linux distro running on your PC, or if you cannot devote an entire computer, a virtual machine with Linux on it.
In my case, I’ve used Ubuntu 16.04. It’s user friendly so I suggest you to use it.
- Linux distro
- At least 200GB of free space on your HDD or SSD.
- Powerful PC, at least 4GB RAM and a good quad core CPU
- Good internet connection, at least 600 KB/s
If you have all the required stuff, then let’s start.
All the commands I’m going to write have to be issued in the Terminal, and of course I won’t repeat this each time.
If it is not already installed, issue this command to install its libraries:
sudo apt-get install openjdk-8-jdk
Issue this command (may take several time according to your internet connection):
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
What is this unknown?
This important tool is needed to contact servers and download the sources you’ll need later. It means ‘Repository’ which is a fancy term for a central location for a specific item. In this case, it specifically means a location to store everything that goes into a compiled, working ROM.
Issue this to setup repo:
mkdir ~/bin && curl http://commondatastorage.googleapis.com/git-repo-downloads/repo > ~/bin/repo && chmod a+x ~/bin/repo
This useful utility is used to cache binaries and to reduce compilation time (-50%).
To setup it, issue:
ccache -M 50G
Of course set the GB according to the space available in your hard drive.
To see ccache stats:
To clean ccache files:
We have almost finished, now open your bash.rc
sudo nano ~/.bashrc
go to last line and insert:
save the file and close the editor, to apply these changes, issue:
That’s it for today!
Here you the other two parts to continue the building!