1. Preparations before Compilation
Check whether the version of the following package is OK:
1.1 gcc4.4 instead of gcc4.6. If it is 4.6, you need to install gcc4.4. The command is as follows:
Sudo apt-Get install gcc-4.4
Sudo apt-Get install g ++-4.4
CD/usr/bin
Ls-l GCC *
Sudo mv gcc. Bak
Sudo ln-s gcc-4.4 gcc
Ls-l g ++ *
Sudo MV g ++. Bak
Sudo ln-s g ++-4.4g ++
Gcc-V
G ++-V
1.2 python2.5-2.7, ubuntu12.04. The default Python version is 2.7.
1.3 Java version: Micro 1.6.0, instead of openjdk. I have deleted the openjdk installation package before, so it should not be correct here.
2. Compile the source code
Follow the official prompts to execute the following commands in sequence:
Source build/envsetup. Sh
Lunch full-Eng
Make-J4
Suggestion: The last command uses make showcommands to display the compilation command, so that it will not be boring when the screen is not output during compilation.
3. Compile error handling
3.1 error: You are attempting to build with the incorrect version of Java.
Solution: sudo Update-alternatives -- config Java. Check the javac and jar commands.
3.2 error: Make: *** [out/host/linux-x86/obj/executables/obbtool_intermediates/Main. O] Error 1
Make: *** waiting for unfinished task ....
Solution: Modify the/build/CORE/Combo/HOST_linux-x86.mk file under the source directory:
Run the following statement:
Host_global_cflags + =-d_fortify_source = 0
Change
Host_global_cflags + =-u_fortify_source-d_fortify_source = 0
3.3 error: Make: *** [out/host/linux-x86/obj/static_libraries/libmesa_intermediates/src/glsl/linker. O] Error 1
Solution:
Gedit external/mesa3d/src/glsl/linker. cpp
In the header file segment, add # include <stddef. h>
3.4 error: Make: *** [out/host/linux-x86/obj/static_libraries/liboprofile_pp_intermediates/arrange_profiles.o]
Solution: Check the GCC and G ++ version 4.4 you are using, instead of the higher version.
3.5 error: Make: *** [out/target/common/obj/apps/ctsverifier_intermediates/classes-full-debug.jar]
Solution: sudo Update-alternatives -- config javac. Select jdk1.6.0 instead of openjdk.
3.6 error: Make: *** [out/target/common/obj/apps/android.core.tests.libcore.package.com. no-core-tests-res_intermediates/noproguard. classes-with-local.dex] killed
Solution: the problem is that compiling android4.0 requires 4 gb ram or swap space, while Ubuntu requires 1 GB space by default. Therefore, you can increase the swap space by executing the following command:
Sudo dd If =/dev/Zero of =/boot/swapfile BS = 1024 COUNT = 4194304
Sudo mkswap-V1/boot/swapfile
Sudo Swapon/boot/swapfile
Free
Sudo VI/etc/fstab
/Boot/swapfile swap defaults 1 1
4. Compilation successful
4.1 After the compilation is successful, system. IMG, ramdisk. IMG, userdata. IMG will be displayed under out/target/product/generic.
4.2 but after compilation, I run the emulator command on the terminal, but the prompt is:
No command 'ulator' found, did you mean:
Command 'qemulator' from package 'qemulator' (universe)
Emulator: Command not found
Solution:
Run the following command again:
Source build/envsetup. Sh
Lunch full-Eng
4.3 emulator running