Compiling Android source code in Ubuntu 11.10 (32-bit System)

Source: Internet
Author: User

This article describes how to compile the android 2.3.3 source code in Ubuntu 11.10. Before compiling, make sure that the preparations required in the last two articles have been completed successfully. After compilation, the system image file is generated and run in the simulator.

After the preparation is complete, start the compilation. The downloaded source code is more than 5 Gb. If you obtain the source code as I wrote earlier, the source code directory is ~ /Android/source

I. Environment Settings

wayne@wayne-pc:~/Android/source$ source build/envsetup.sh 
including device/htc/passion/vendorsetup.sh
including device/samsung/crespo/vendorsetup.sh
wayne@wayne-pc:~/Android/source$ lunch full-eng

In lunch, if the prompt "Permission denied" is insufficient, run the command in the source code root directory to grant all file permissions in the directory.

wayne@wayne-pc:~/Android/source$ sudo chmod -R 777 *

At this time, the lunch command will print out the following text:

============================================
PLATFORM_VERSION_CODENAME=REL
PLATFORM_VERSION=2.3.3
TARGET_PRODUCT=full
TARGET_BUILD_VARIANT=eng
TARGET_SIMULATOR=false
TARGET_BUILD_TYPE=release
TARGET_BUILD_APPS=
TARGET_ARCH=arm
HOST_ARCH=x86
HOST_OS=linux
HOST_BUILD_TYPE=release
BUILD_ID=GRI40
============================================

1. Start Compilation

The compilation process may be aborted due to many errors. Here, Wayne will post all the problems and solutions for future reference.

1. Q:

Wayne @ Wayne-PC :~ /Android/source $ make-J2
========================================================== ====
Platform_version_codename = REL
Platform_version = 2.3.3
Target_product = full
Target_build_variant = ENG
Target_simulator = false
Target_build_type = release
Target_build_apps =
Target_arch = arm
Host_arch = x86
Host_ OS = Linux
Host_build_type = release
Build_id = gri40
========================================================== ====
Checking build Tools versions...
Build/CORE/main. MK: 76: **************************************** ********************
Build/CORE/Main. mk: 77: You are attempting to build on a 32-bit system.
Build/CORE/Main. mk: 78: only 64-bit build environments are supported beyond froyo/2.2.
Build/CORE/main. MK: 79: **************************************** ********************
Build/CORE/Main. mk: 80: *** stop. Stop.

Solution: Run cd in the source code root directory and execute:

$ gedit build/core/main.mk

Find

ifneq (64,$(findstring 64,$(build_arch)))

Modify it

ifneq (i686,$(findstring i686,$(build_arch)))

Modify the following four make files in sequence:

external/clearsilver/cgi/Android.mk
external/clearsilver/java-jni/Android.mk
external/clearsilver/util/Android.mk
external/clearsilver/cs/Android.mk

Replace

LOCAL_CFLAGS += -m64
LOCAL_LDFLAGS += -m64

Change

LOCAL_CFLAGS += -m32
LOCAL_LDFLAGS += -m32

2. Q:

frameworks/base/libs/utils/RefBase.cpp:483:67: error: passing ‘const android::RefBase::weakref_impl’ as ‘this’ argument of ‘void android::RefBase::weakref_impl::trackMe(bool, bool)’ discards qualifiers [-fpermissive]
make: *** [out/host/linux-x86/obj/STATIC_LIBRARIES/libutils_intermediates/RefBase.o] Error 1

Solution:

$ gedit frameworks/base/libs/utils/Android.mk

Modify the following statement

LOCAL_CFLAGS += -DLIBUTILS_NATIVE=1 $(TOOL_CFLAGS)

Is

LOCAL_CFLAGS += -DLIBUTILS_NATIVE=1 $(TOOL_CFLAGS) –fpermissive

3. Q:

arm-eabi-gcc: error trying to exec 'cc1': execvp: No such file or directory
make: *** [out/target/product/generic/obj/lib/crtbegin_dynamic.o] Error 1

If the previous dependency packages have been successfully installed, the cross-compilation tool permission is required. This problem should not occur if you execute the grant permission command at the beginning of the article lunch.

4. Q:

<command-line>:0:0: error: "_FORTIFY_SOURCE" redefined [-Werror]
<built-in>:0:0: note: this is the location of the previous definition
cc1plus: all warnings being treated as errors
make: *** [out/host/linux-x86/obj/EXECUTABLES/obbtool_intermediates/Main.o] Error 1

The compilation error here is caused by the use of gcc4.6.1 in Ubuntu 11.10.

Solution:

Modify the/build/CORE/Combo/HOST_linux-x86.mk file in the source code directory:

Run the following statement:

HOST_GLOBAL_CFLAGS += -D_FORTIFY_SOURCE=0

Change

HOST_GLOBAL_CFLAGS += -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=0

 

Similar errors may occur during compilation. Keywords prompted by errors, such as G ++ errors and JRE errors, are all detailed issues and are better solved.

After about two hours of waiting, it was finally completed successfully. After compilation is successful, system. IMG and other image files will be generated. The following is the compilation completion prompt:

Target system fs image: out/target/product/generic/obj/PACKAGING/systemimage_intermediates/system.img
Install system fs image: out/target/product/generic/system.img
Installed file list: out/target/product/generic/installed-files.txt

 

3. Start the compiled System

After compilation, the system. IMG ramdisk. IMG userdata. IMG image files are generated in the out/target/product/Generic Directory.

Before starting the simulator, you must set environment variables for the simulator system and execute gedit ~ /. Bashrc. Add the following environment variables:

export ANDROID_PRODUCT_OUT=~/Android/source/out/target/product/generic
ANDROID_PRODUCT_OUT_BIN=~/Android/source/out/host/linux-x86/bin
export PATH=${PATH}:${ANDROID_PRODUCT_OUT_BIN}:${ANDROID_PRODUCT_OUT};

Finally, synchronize these changes and start the simulator:

$ source ~/.bashrc
$ cd ~/Android/source/out/target/product/generic
$ emulator -system system.img -data userdata.img -ramdisk ramdisk.img

After loading the system files we compiled, we finally came up with a long-awaited simulator:

By now, the source code compilation is complete, and you can test your own changes. Still, please let us know by Wayne!

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.