Android source code compilation

Source: Internet
Author: User

Android source code compilation
Brief Description

Nowadays, open-source Android Application Development Projects feel like various ideas spring and autumn, such as algorithms and shapes, such as databases, such as network protocols, github has also become a paradise for open-source users and beneficiaries. Now we will follow the steps of open-source, follow the dazzling stars, stand on the shoulders of giants, and start our path to growth.

The Open Source of Android source code is also the largest open source. Of course, some people will say that open source is not open source, so we don't have to worry about it. It is good to download the system code we need. Downloading and compiling the Android source code is still a headache for beginners. Let's start from here.

Download and install the vmvm and ubuntu ios files

The version I selected here is 7.1.5 build-491717, ubuntu-11.04-desktop-i386

Prerequisites

Originally, the source code of version 4.4.1 was selected. However, the source code is too large and exceeds the 50 GB hard disk of the virtual machine I set. It is estimated that compilation will take a long time. Later, I chose the source code version 2.3.1. before downloading the source code, I had to make some preparations.

Buy a stable VPN. This is the download source code and required software.

Install the Git Tool

Sudo apt-get install git-core gnupg

Install Jdk

The following commands are frequently used to add and update software sources.

Sudo add-apt-repository ppa: ferramrobert to/java

Sudo apt-get update

Install

Sudo apt-get install sun-java6-jre sun-java6-plugin

Sudo apt-get install sun-java6-jdk

 

Download repo and Set permissions

Wget https://dl-ssl.google.com/dl/googlesource/git-repo/repo

Chmod 777 repo

Cp repo/bin/

Create an Android folder and switch to its Directory

Mkdir Android

Cd Android

Download android source code

The latest version is downloaded by default.

Repo init-u www.bkjia.com

I specified the 2.3.1 version branch.

Repo init-u https://android.googlesource.com/platform/manifest-B android-2.3.1_r1

Then download

Repo sync

Downloading is a long process. It requires a stable network speed and a great firewall. Generally, it takes 2 ~ 3 days, the total size is 4 ~ 5G. If the speed is fast, it may not take that long.

Okay. The download looks like

Make Compilation

Make

When the download is complete, do not think it is over. The problem is just getting started. Why do we say this, because various problems may occur during compilation, mainly in two aspects:

Error message: You are attempting to build on a 32-bit system.

Comment out the 64-bit script here.

Modify the main. mk file in the build/core directory:

Ifeq ($ (BUILD_ OS), linux)

Build_arch: = $ (shell uname-m)

# Change the following line for building on a 32-bit system.

# Ifneq (64, $ (findstring 64, $ (build_arch )))

# $ (Warning ************************************ ************)

# $ (Warning You are attempting to build on a 32-bit system .)

Find and comment out the following files:

/External/clearsilver/cgi/Android. mk

/External/clearsilver/cs/Android. mk

/External/clearsilver/java-jni/Android. mk

/External/clearsilver/util/Android. mk

Modify the variables LOCAL_CFLAGS and LOCAL_LDFLAGS:

# This forces a 64-bit build for Java6

# Change the following two lines for building on a 32-bit system.

# LOCAL_CFLAGS + =-m64

# LOCAL_LDFLAGS + =-m64

 

The second problem is that the software is not installed.

Therefore, it is best to install these software before compilation. Otherwise, it will take a long time for a problem to occur during compilation, and we will try again. That is a Sang Xin.

Sudo apt-get install bison

Sudo apt-get install bison flex

Sudo apt-get install zlib-devel

Sudo apt-get install libncurses5-dev

Sudo apt-get install libx11-dev

Sudo apt-get install gperf

For other similar problems, baidu should look at which one is missing, and then execute it. If this is not found, it will look for the source in which he is located, add it to our software source file and initialize it again.

Well, the following is the message output after Make is successful. Are you very excited?

 

Emulator startup Simulator

This step is much simpler. Add the compiled output bin to the environment variable.

Export PATH = $ PATH :~ /Android/out/host/linux-x86/bin

Export ANDROID_PRODUCT_OUT = ~ /Android/out/target/product/generic

Run emulator

Emulator

The following is our long-awaited interface. Seeing this, the previous payment is also rewarded.

 

PS: It is really troublesome to edit text. There are no styles in the world, and offline editing is not supported.

Related Article

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.