Android 4.0.1 Source Code compilation

Source: Internet
Author: User
Tags gnupg

When learning the application programming, in order to realize the application in the background to the other interface control, need to increase the application permissions to the system level.
But the way to the system level, one of which is put in the Android source code directory to compile, another method has been tried, but the installation failed.
Started trying to get the Android source directly from Google's website, but was unable to get it because of the mainland's blockade of Google. Everyone gets it through a VPN, but a general VPN is a cost.
Later will get the Android source code direction to others download good, packaged to the Internet.
Successively from the XX cloud disk downloaded 3 Android source code compression package, respectively:
Repo.tar.gz 12.2GB
Working_directory.tar 12.4GB
Android4.0.tar.gz 1.73GB
The first two have not been used before, using android4.0.tar.gz to test.

Unzip ANDROID4.0.TAR.GZ:TAR-ZXVF android4.0.tar.gz first in Ubuntu

Install the Jdk-6u45-linux-i586.bin, download from the Oracle website and need to register with Oracle.
Get jdk-6u45-linux-i586.bin download URL: Google "Jdk-6u45-linux" to get the first search results:
Http://www.oracle.com/technetwork/java/javase/downloads/java-archive-downloads-javase6-419409.html
Note: Do not use the OPEN-JDK version provided by Ubuntu.

Installation process:
(1) Give execute permission, enter in Terminal: chmod a+x Jdk-6u45-linux-i586.bin
(2) Unzip, enter in Terminal:./jdk-6u45-linux-i586.bin
(3) Create the JVM directory and enter it in Terminal: sudo MKDIR/USR/LIB/JVM
(4) Move the Extract file and enter it in Terminal: sudo mv ~/androidsource/android4.0/jdk1.6.0_45/usr/lib/jvm/jdk1.6.0_45
(5) To enable JDK 6, enter in Terminal:
sudo ln-s-b/usr/lib/jvm/jdk1.6.0_45/jre/bin/java/etc/alternatives/java
sudo ln-s-b/usr/lib/jvm/jdk1.6.0_45/jre/bin/java/usr/bin/java
(6) test, enter in Terminal: Java-version
The results should show:
Java Version "1.6.0_45"
(7) Edit the configuration file, enter in terminal: sudo vim/etc/profile
Add the following entry at the end of the file:
Java_home=/usr/lib/jvm/jdk1.6.0_45
Export JRE_HOME=/USR/LIB/JVM/JDK1.6.0_45/JRE
Export classpath=.: $JAVA _home/lib: $JRE _home/lib: $CLASSPATH
Export path= $JAVA _home/bin: $JRE _home/bin: $PATH
#set Java Environment
Here to modify the above content according to their own installation path! After rebooting the system, the Java environment is installed.
Note: Vim operation instruction, (1) Insert button; (2):; (3)!; (4) w/q

Start compiling the Android source code, enter the directory: ~/androidsource/android4.0, enter the following command:
#make Installclean
#make Clean
#source build/envsetup.sh
#lunch Select version number: Lunch Full-eng
1. Full-eng
2. Full_x86-eng
3. Vbox_x86-eng
4. Full_maguro-userdebug
5. Full_tuna-userdebug
6. Full_panda-eng
Which would you like [Full-eng] 5
#make-j4 where-J (n) means compiling with the N-core CPU

If the error is as follows, resolve it by the corresponding method:
(1) Ubuntu bison: no command found
sudo apt-get install g++
(2) Ubuntu g++: no command found
sudo apt-get install Bison
(3)/usr/bin/ld:cannot Find-lz
Detailed information is as follows:
Host C:libpng <= EXTERNAL/LIBPNG/PNGWTRAN.C
Host C:libpng <= EXTERNAL/LIBPNG/PNGWUTIL.C
Host Staticlib:libpng (OUT/HOST/LINUX-X86/OBJ/STATIC_LIBRARIES/LIBPNG_INTERMEDIATES/LIBPNG.A)
Host Executable:aapt (OUT/HOST/LINUX-X86/OBJ/EXECUTABLES/AAPT_INTERMEDIATES/AAPT)
/usr/bin/ld:cannot Find-lz
Collect2:ld returned 1 exit status
Make: * * [OUT/HOST/LINUX-X86/OBJ/EXECUTABLES/AAPT_INTERMEDIATES/AAPT] Error 1
Workaround:
Updated the installation of the tool as follows:
sudo apt-get install Git-core GnuPG Flex Bison gperf build-essential Zip curl zlib1g-dev Libc6-dev Libncurses5-dev X11prot O-core-dev libx11-dev libreadline6-dev libgl1-mesa-dev tofrodos python-markdown libxml2-utils Xsltproc
You can continue compiling.

Error 1:
A hint occurred during compilation: The process was killed by the error, and the phenomenon was terminated.
No specific errors were recorded at the time and the recompilation was OK.
------Re-execution: make-j2

Error 2:
T_intermediates/src-api Out/target/common/obj/packaging/public_api.txt-nodocs
Make: * * is waiting for unfinished tasks ....
Make: * * [Out/target/common/docs/api-stubs-timestamp] Error 45
Workaround (Use Method 2):
(1) A workaround on the web (but there is no clearsilver directory in my extenal directory (some say this applies to: Android 2.3))
This is because Clearsilver uses 64-bit compilation when it detects the use of Java JDK 6 at compile time. To avoid this error, you need to modify the following four files:
External/clearsilver/cgi/android.mk
External/clearsilver/java-jni/android.mk
External/clearsilver/util/android.mk
External/clearsilver/cs/android.mk
Note the following statements in the four makefile:
# This forces a 64-bit build for JAVA6
# Comment by Easwy
# Local_cflags + =-m64
# Local_ldflags + =-m64
Then execute make clean in the External/clearsilver directory, then go back to the project root and continue with make.
(2) Make Clear/make Update-api/make
(3) Make: * * * [Out/target/common/docs/doc-comment-check-timestamp] Error 45
WORKAROUND: You need to make a link as follows:
sudo ln-s/usr/lib/jvm/jdk1.6.0_45/bin/jar/bin/jar
sudo ln-s/usr/lib/jvm/jdk1.6.0_45/bin/java/bin/java
sudo ln-s/usr/lib/jvm/jdk1.6.0_45/bin/javac/bin/javac
sudo ln-s/usr/lib/jvm/jdk1.6.0_45/bin/javah/bin/javah
sudo ln-s/usr/lib/jvm/jdk1.6.0_45/bin/javadoc/bin/javadoc

Error:
prebuilt/linux-x86/toolchain/arm-linux-androideabi-4.4.x/bin/arm-linux-androideabi-ar:out/target/product/ Generic/obj/static_libraries/libwebcore_intermediates/libwebcore.a:no space left on device
Make: * * [OUT/TARGET/PRODUCT/GENERIC/OBJ/STATIC_LIBRARIES/LIBWEBCORE_INTERMEDIATES/LIBWEBCORE.A] Error 1
Make: * * * Deleting file "Out/target/product/generic/obj/static_libraries/libwebcore_intermediates/libwebcore.a"
Cause: Insufficient space causes compilation to break

mount a 20G empty partition and re-unzip ANDROID4.0.TAR.GZ:TAR-ZXVF android4.0.tar.gz
Make Installclean
Make clean
Make Update-api
SOURCE build/envsetup.sh
Make-j2

Error:
nd/m_demangle/cplus-dem.c:2865:error:undefined reference to ' vgplain_strcspn '
prebuilt/linux-x86/toolchain/arm-linux-androideabi-4.4.x/bin/. /lib/gcc/arm-linux-androideabi/4.4.3/. /.. /.. /.. /arm-linux-androideabi/bin/ld:out/target/product/generic/obj/static_libraries/libcoregrind-arm-linux_ INTERMEDIATES/LIBCOREGRIND-ARM-LINUX.A (CPLUS-DEM.O): in function gnu_special:external/valgrind/main/coregrind/m_ demangle/cplus-dem.c:2926:error:undefined reference to ' VGPLAIN_STRPBRK '
Collect2:ld returned 1 exit status
Make: * * * [out/target/product/generic/obj/shared_libraries/cachegrind-arm-linux_intermediates/linked/ Cachegrind-arm-linux] Error 1
Cause: no lunch executed

Error:
Target Staticlib:libwebcore (OUT/TARGET/PRODUCT/TUNA/OBJ/STATIC_LIBRARIES/LIBWEBCORE_INTERMEDIATES/LIBWEBCORE.A)
prebuilt/linux-x86/toolchain/arm-linux-androideabi-4.4.x/bin/arm-linux-androideabi-ar:out/target/product/tuna/ Obj/static_libraries/libwebcore_intermediates/libwebcore.a:no space left on device
Make: * * [OUT/TARGET/PRODUCT/TUNA/OBJ/STATIC_LIBRARIES/LIBWEBCORE_INTERMEDIATES/LIBWEBCORE.A] Error 1
Make: * * * Deleting file "Out/target/product/tuna/obj/static_libraries/libwebcore_intermediates/libwebcore.a"
/usr/bin/ld:final Link Failed:no space left on device
Collect2:ld returned 1 exit status
Make: * * is waiting for unfinished tasks ....
Make: * * [out/host/linux-x86/obj/lib/libbcc.so] Error 1

mount a 20G empty partition after compiling the source code of Android 4.0.1, still appears: No space left on device. So a cruel, will now use the Ubuntu virtual machine removed, rebuild a 80G virtual machine.
With Ubuntu 10.04, no upgrades are made after installation.
The following is a record of the disk's remaining space during the operation:
(1) 80G remaining 69.7 GB after installing Ubuntu
(2) After copying android4.0.tar.gz and Jdk-6u45-linux-i586.bin, unzip: 61.4 GB remaining after TAR-ZXVF android4.0.tar.gz
(3) When you are ready to compile the environment (delete android4.0.tar.gz and Jdk-6u45-linux-i586.bin), the remaining space 62.9 GB
Start compiling Android 4.0.1 source code.
If an error occurs during compilation, do not attempt to resolve it as long as the configuration of the compilation environment is correct. Just need a simple recompile! After the compilation succeeds, the remaining space is 51.1 GB.
Compile Android 4.0.1 source code, need at least 18.6G of hard disk space.


LOG at the end of successful compilation:
Target System FS Image:out/target/product/tuna/obj/packaging/systemimage_intermediates/system.img
In mkuserimg.sh path=out/host/linux-x86/bin/:/usr/lib/jvm/java-6-sun/bin:/usr/lib/jvm/jdk1.6.0_45/bin:/usr/lib/ Jvm/jdk1.6.0_45/jre/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/home/leozheng /android4.0/out/host/linux-x86/bin:/home/leozheng/android4.0/prebuilt/linux-x86/toolchain/ arm-linux-androideabi-4.4.x/bin:/home/leozheng/android4.0/development/emulator/qtools:/home/leozheng/ android4.0/prebuilt/linux-x86/toolchain/arm-linux-androideabi-4.4.x/bin:/home/leozheng/android4.0/prebuilt/ Linux-x86/toolchain/arm-eabi-4.4.3/bin
Make_ext4fs-s-L 685768704-a system out/target/product/tuna/obj/packaging/systemimage_intermediates/system.img out/ Target/product/tuna/system
Creating filesystem with Parameters:
size:685768704
Block size:4096
Blocks per group:32768
Inodes per group:6976
Inode size:256
Journal blocks:2616
Label:
blocks:167424
Block Groups:6
Reserved Block Group size:47
Created filesystem with 904/41856 inodes and 41089/167424 blocks
Install System FS Image:out/target/product/tuna/system.img
Out/target/product/tuna/system.img+out/target/product/tuna/obj/packaging/recovery_patch_intermediates/recovery _FROM_BOOT.P Total size is 159017016

Start the compiled Android 4.0.1 simulator
[Email protected]:~$ ls
android4.0 Documents examples.desktop Pictures Templates
Desktop Downloads Music Public Videos
[Email protected]:~$ cd Android4.0/out/host/linux-x86/bin
Follow the on-line instructions to access the SDK directory. However, this directory does not exist and will prompt bash:cd:sdk:No such file or directory
[Email protected]:~/android4.0/out/host/linux-x86/bin$ ls
......
[Email protected]:~/android4.0/out/host/linux-x86/bin$ ls em*
Emulator Emulator-arm Emulator-ui emulator-x86
[Email protected]:~/android4.0/out/host/linux-x86/bin$./emulator
Emulator:ERROR:You did not specify a virtual device name, and the system
Directory could not being found.
If you are a Android SDK user, please use ' @<name> ' or '-avd <name> '
To start a given virtual device (SEE-HELP-AVD for details).

Otherwise, follow the instructions in-help-disk-images to start the emulator

[Email protected]:~/android4.0/out/host/linux-x86/bin$./emulator list targets
Invalid command-line parameter:list.
Hint:use ' @foo ' to launch a virtual device named ' foo '.
Use-help for more information
[Email protected]:~/android4.0/out/host/linux-x86/bin$ ls an*
Android
[Email protected]:~/android4.0/out/host/linux-x86/bin$ android list targets
Android:command not found
[Email protected]:~/android4.0/out/host/linux-x86/bin$./android list targets
SWT folder '/home/leozheng/android4.0/out/host/linux-x86/framework/x86 ' does not exist.
Please export ANDROID_SWT to the folder containing Swt.jar for your platform.
[Email protected]:~/android4.0/out/host/linux-x86/bin$ export Path=~/android4.0/out/host/linux-x86/bin: $PATH
[Email protected]:~/android4.0/out/host/linux-x86/bin$ Export android_product_out=~/android4.0/out/target/product /generic
[Email protected]:~/android4.0/out/host/linux-x86/bin$ Emulator
Emulator:ERROR:Can ' t access android_product_out as '/home/leozheng/android4.0/out/target/product/generic '
You need to build the Android system before launching the emulator
[Email protected]:~/android4.0/out/host/linux-x86/bin$ CD.
[Email protected]:~/android4.0/out/host/linux-x86$ CD.
[Email protected]:~/android4.0/out/host$ CD.
[Email protected]:~/android4.0/out$ ls
Casecheck.txt CaseCheck.txt Host Target Versions_checked.mk
[Email protected]:~/android4.0/out$ cd target/
[Email protected]:~/android4.0/out/target$ ls
Common product
[Email protected]:~/android4.0/out/target$ CD Product
[Email protected]:~/android4.0/out/target/product$ ls
Tuna
[Email protected]:~/android4.0/out/target/product$ CD Tuna
[Email protected]:~/android4.0/out/target/product/tuna$ ls
Android-info.txt Kernel recovery.img
Boot.img obj Root
Clean_steps.mk previous_build_config.mk Symbols
Data ramdisk.img System
Fake_packages ramdisk-recovery.img system.img
Installed-files.txt Recovery userdata.img
[Email protected]:~/android4.0/out/target/product/tuna$ Export android_product_out=~/android4.0/out/target/ Product/tuna
[Email protected]:~/android4.0/out/target/product/tuna$ Emulator
Emulator started successfully, running ...

If prompted:
Emulator:WARNING:system partition size adjusted to match image file (Mb > MB)
Emulator:WARNING:data partition size adjusted to match image file (135 MB > (MB))
Emulator:emulator window was off of view and was recentered
If you use a notebook (1280*800 resolution), the display area of the skin is too large, the keyboard part may appear incomplete, inconvenience to use

The following online record of the people who compiled Android V4.0.1 encountered problems and solutions:
(*) Usr/bin/ld:cannot find libncurses.so.5 cannot FIND-LGL
sudo apt-get install Git-core GnuPG Flex Bison gperfbuild-essential Zip curl zlib1g-dev Libc6-dev Lib32ncurses5-dev ia32-l Ibsx11proto-core-dev Libx11-dev Lib32readline5-dev Lib32z-dev libgl1-mesa-devg++-multilib
Workaround:
sudo ln-s/usr/lib/i386-linux-gnu/libx11.so.6/usr/lib/i386-linux-gnu/libx11.so

(* *)
Host Sharedlib:lib64egl_translator (out/host/linux-x86/obj/lib/lib64egl_translator.so)
/usr/bin/ld:cannot FIND-LGL
Collect2:ld returned 1 exit status
Make: * * * [out/host/linux-x86/obj/lib/lib64egl_translator.so] Error 1
Make: * * * waiting for unfinished jobs ....
Workaround:
sudo apt-get install Libglu1-mesa-dev

NDK Installation
Http://developer.android.com/tools/sdk/ndk/index.html
ndk$ chmod a+x Android-ndk-r10c-darwin-x86_64.bin
ndk$./android-ndk-r10c-darwin-x86_64.bin

**Q)
Host Sharedlib:lib64egl_translator (out/host/linux-x86/obj/lib/lib64egl_translator.so)
/usr/bin/ld:cannot FIND-LGL
Collect2:ld returned 1 exit status
Make: * * * [out/host/linux-x86/obj/lib/lib64egl_translator.so] Error 1
Make: * * * waiting for unfinished jobs ....
Workaround:
sudo apt-get install Libglu1-mesa-dev

(*)
Host Staticlib:libglcommon (Out/host/linux-x86/obj/static_libraries/libglcommon
_INTERMEDIATES/LIBGLCOMMON.A)
Host Sharedlib:libgles_cm_translator (Out/host/linux-x86/obj/lib/libgles_cm_tra
nslator.so)
/usr/bin/ld:cannot FIND-LGL
Collect2:ld returned 1 exit status
Make: * * * [out/host/linux-x86/obj/lib/libgles_cm_translator.so] Error 1
Workaround:
sudo ln-s/usr/lib/i386-linux-gnu/mesa/libgl.so.1.2/usr/lib/libgl.so

Android 4.0.1 Source Code compilation

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.