Android source code compilation in Mac OS X 10.6

Source: Internet
Author: User
Android source code compilation in Mac OS X 10.6

1. At least 8 GB of case sensitive partitions are required

Compiling Android source code on Mac requires a case sensitive partition format. If your original partition is not a HFS file format, the simplest way is to create a new DMG partition format. The command is as follows:

Sudo hdiutil create-size 8G-type udif-Fs hfsx-volname Android ~ /Android. DMG
Sudo chown $ user ~ /Android. DMG

You can also use the disk tool to create a DMG image file. The procedure is as follows:

1) Start/application/utility/disk tool in the finder;

2) select new image;

3) select the target location, which is usually stored in the user's directory;

3) Custom Size: 8 GB;

4) Select the Mac OS extension format (case sensitive, log type ).

Then edit your ~ /. Bash_profile file. If it does not exist, create it and add the following content:

# Command to mount the android file Image
Function mountandroid {hdiutil attach ~ /Android. DMG-mountpoint/volumes/android ;}

Then you can use mountandroid to mount your image file to the/volumes/Android directory.
2. Download the code or directly copy the existing source code to the/volumes/Android directory.

To download the source code, you must install the repo tool to better use the GIT source code management software (similar to version control systems such as CVS). Run the following command to create ~ /Bin directory:

$ Cd ~
$ Mkdir Bin
$ Echo $ path

Download repo:

$ Curl https://android.git.kernel.org/repo> ~ /Bin/Repo
$ Chmod A + x ~ /Bin/Repo

Then, create the android directory under the/volumes/Android directory to store the android source code:

$ CD/volumes/android
$ Mkdir android
$ CD android

Then initialize the repo client:

$ Repo init-u git: // android.git.kernel.org/platform/manifest.git

After successful display:

Repo initialized in/volumes/Android/android

In this case, the. Repo directory will be in the/volumes/Android directory to synchronize the manifest file. The file is used to synchronize the source code. Download the source code and run the following command:

$ Repo sync

Download 4G files, all of which will take a long time.

It is very important to install several patches after the download is complete. Execute the following commands and install the following four patches in sequence:
CD build
Git pull git: // android.git.kernel.org/platform/build refs/changes/74/12074/3

CD system/Core
Git pull git: // android.git.kernel.org/platform/system/core refs/changes/45/11845/3

CD external/qemu
Git pull git: // android.git.kernel.org/platform/external/qemu refs/changes/46/11846/3

CD system/Core
Git pull git: // android.git.kernel.org/platform/system/core refs/changes/97/12597/1

3. Download and install xcode and macports

First download and install the latest xcode: http://developer.apple.com
Then download macports,: http://www.macports.org/run tar-zxvf tarfilename command unzip, switch to the decompressed directory and install:
$./Configure
$ Make
$ Sudo make install
Then modify ~ /. Bash_profile file, add:
Export Path =/opt/local/bin: $ path
Then execute the command to make the macport self-update:
$ Sudo port selfupdate
Install the required package from the port
$ Posixly_correct = 1 sudo port install gmake libsdl Git-core GnuPG
Update GNU to the latest version:
$ Sudo ln-s gmake/opt/local/bin/make

Modify ~ /. Bash_profile file, add:
# Set the number of open files to be 1024
Ulimit-S-n 1024
4. Compile the source code

First modify ~ /. Bash_profile file, add:
Path = $ path:/volumes/Android/bin
# Java_home =/usr/bin
Java_home =/library/Java/home
Android_product_out =/volumes/Android/out/target/product/generic
Android_product_out_bin =/volumes/Android/out/host/darwin-x86/bin
Path =$ {path }:$ {android_product_out_bin }:: {android_product_out }:~ /Eclipse
Export path java_home android_product_out
Open a new command line window and execute the following command:
$ CD/volumes/Android/android
$ Make
The source code compilation takes a long time, which may take about 4 ~ Wait for 5 hours. After compilation, run the following command:
$ Emulator
The simulator will be called up, indicating that the compilation is successful!
5. Common Errors. Welcome to feedback!

1. An error occurred while completing the patch. The error is as follows:
"Pull is not possible because you have unmerged files.
Please, fix them up in the work tree, and then use 'git Add/RM'
As appropriate to mark resolution, or use 'git commit-'."
Use the following command:
"Git clone git: // android.git.kernel.org/platform/system/core refs/changes/97/12597/1 ″

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.