story background:
A month ago, I accidentally saw that the native Email application and SMS application of Android 4.4 had several features that I thought were cool, and I really wanted to know how Google programmers implemented them. So I started the journey of downloading and compiling the android4.4 source code on ubuntu12.04. Unexpectedly, this journey took more than a month! ! (I have experience compiling android source code)
Preface:
I'm a little excited to write this blog because I haven't had the habit of blogging before. For a programmer who has experience compiling Android source code, it took more than a month to walk a path that I thought was familiar to me, forcing me to record this long, torturous, exciting, desperate, and exciting journey. . I want to complain and curse, why is the experience of compiling source code a year ago useless a year later? To sum up, China blocks some Hehe technical websites from time to time, causing mainland programmers to feel extremely depressed. It can take an hour to complete a task, but it takes a day and a week to set up. This is something that technology geeks from other regions cannot feel, fuck, fuck, fuck! The only thing this environment brings us is greater patience and the spirit of not giving up. Everything has pros and cons, but with this kind of pros, I still want to say fuck you!
text:
Non-Mainland programmers can follow the official technical documentation step by step and there should be no problem. If you have any questions, please ask for help: [email protected]. Send an email to this organization. Since most of the organization is controlled by foreign technology, the content of the email should preferably be in English. Except for the technical fans in mainland China, if you follow the official steps, there will generally be no problems. To summarize some experiences: If you encounter problems during compilation, you can search online. If you find results, try to solve them according to the suggestions of netizens. If you can't find any results, it must be caused by your environment or incoherent compilation. First, check the environment first. Before installing tools, check whether the system has built-in default tools. If the requirements are met, use the system tools first. If you are not satisfied, uninstall and reinstall. It is best to install all unknown tools. Do not use the update-alternatives --install command to selectively install them. It is very likely that you will not be sure. Directly configuring the environment variable PATH is more reliable. Second, ensure the continuity of the make command, which means that you cannot accidentally shut down the machine during make, or accidentally interrupt the mid-end compilation process for other reasons. If this happens, then make clean and recompile, otherwise you will encounter problems during most compilations. Everyone knows the official document path, http://source.android.com/
Mainland programmers should not trust official documents and can only refer to them. I still think it is more practical to read the following content.
environment:
ubuntu12.04
64-bit CPU processor
6G memory (preferably)
Hard drive 55G or above
I have dual operating systems installed on my laptop. If the system configuration is better, I can use a virtual machine.
Part 1: Source code download:
1. Install git and curl tools.
Execute in shell window:
sudo apt-get install git-core curl
2. Download the repo, python script: (The address in the official document has been harmonized)
mkdir ~/bin
curl "http://php.webtutor.pl/en/wp-content/uploads/2011/09/repo" > ~/bin/repo
chmod a+x ~/bin/repo
3. Initialize repo
mkdir ~/dir_name
cd dir_name
Using this path, the official download path always hangs, which is very annoying!
repo init -u git://git.omapzoom.org/platform/manifest -b android-4.4_r1
4. Download source code
Copy the following content into your newly created sh file, grant execution permissions and execute it.
#! /bin/bash
repo sync
while [ $? = 1 ]; do
sleep 5
repo sync
done
After the first repo sync, it is best to execute the repo sync command again to ensure that the file is downloaded correctly and in the correct format to ensure that subsequent compilations pass.
Chapter 2, compiling source code
It seems that the system tools do not need to install python or GNU Make tools. The ones that come with the system are just right. We only need to install jdk and some other accessories.
1. Install jdk1.6:
download:
http://www.oracle.com/technetwork/java/javase/archive-139210.html
It is a *.bin format file, about 68MB
Place jdk-6u33-linux-i586.bin in the /usr/lib/jvm/java/ directory and add execution permissions to jdk-6u33-linux-i586.bin chmod u+x /usr/lib/jvm/java
/ jdk-6u33-linux-i586.bin
Execute jdk-6u33- linux -i586.bin and unpack the JDK6 related files to the jdk1.6.0_33 directory./jdk-6u33-linux-i586.bin
Configure environment variables:
sudo vi /etc/profile
Add the following content to the end of the file, pay attention to check the path:
export JAVA_HOME=/usr/local/java/jdk1.6.0_45
export CLASSPATH=.:$JAVA_HOME/lib:$JAVA_HOME/jre/lib:$CLASSPATH
export PATH=$JAVA_HOME/bin:$PATH
This must be executed, otherwise the environment variables will be invalid.
source /etc/profile
Check whether the installation is successful. If a version number appears, the installation is successful:
java -version
2. Install the auxiliary compilation package:
$ sudo apt-get install git gnupg flex bison gperf build-essential \
zip curl libc6-dev libncurses5-dev:i386 x11proto-core-dev \
libx11-dev:i386 libreadline6-dev:i386 libgl1-mesa-glx:i386 \
libgl1-mesa-dev g++-multilib mingw32 tofrodos \
python-markdown libxml2-utils xsltproc zlib1g-dev:i386
为libGL.so建立link
$ sudo ln -s /usr/lib/i386-linux-gnu/mesa/libGL.so.1 /usr/lib/i386-linux-gnu/libGL.so
3. Go to the source code root directory and start compiling:
Set the cache directory to speed up compilation:
export USE_CCACHE=1
export CCACHE_DIR=<path-to-your-cache-directory>
prebuilts/misc/linux-x86/ccache/ccache-M50G
Initialize environment variables:
. build/envsetup.sh
Initialize compilation type:
lunch aosp_arm-eng (many types, please refer to the official documentation for this, the current type is suitable for debug development of the construction simulator)
Start compiling:
make -j16
If the compilation process is interrupted, be sure to clean and recompile.
4. Run:
Run the emulator and start the ddms monitor.
emulator & ddms
To compile a module separately, use the command mmm:
For example, compile system SMS Mms:
mmm package/apps/Mms
After compilation, regenerate the system image system.img. Restart the simulator to see the modification effect:
make snod.
QQ: 915270002 Welcome to join QQ to communicate and indicate the android source code club.
Recommend an article:
A grassroots programmer’s reflections on his entrepreneurial journey-2016