Android source download under Mac

Source: Internet
Author: User
Tags using git

Document Description:

1, the main reference Android's official website: http://source.android.com/source/initializing.html.

2, I use the hardware configuration: MacBook pro,mountain Lion (10.8) system.

3, the steps described in this article are performed step-by-step by the author, but are definitely not the only steps, and some of the small details of the steps can be used by the reader in various ways.

4, the command statement entered in terminal with the $ flag

The first step is to create the disk image (first use, perform this step)

Note: Although the MAC system holds the case of the file name, it does not differentiate the case of the file name (file.sh file.sh is the same file). To avoid problems with git capitalization, we recommend that you place the path to the download source code on a case-sensitive disk.

Open Disk Utility (disk utility)--new image, such as creating a disc image file:


Where the name Android_source, the software is automatically added _DMG, both the disk is hung after the disk is named, ANDROID_SOURCE_DMG. You need to use this name when switching to this disk.

Second step, download the environment configuration (first use, perform this step)

1,xcode, Apple's development tool, can be easily downloaded from the App Store. Different source code required by the minimum version is not the same, the author of the Mac is 10.8, all versions are currently available for download, in particular, can refer to the official website.

2,command line tools, after installing Xcode, open preferrences-->downloads, you can download the tool, such as:

3, install MacPorts

To verify the installation, you can enter it in the terminal

$ sudo port

command line to determine if it exists. Otherwise it can be installed according to the required steps of the official website http://www.macports.org/install.php (Installation of Xcode and command line tools is required before installation of the software).

4. Install the required software
Execute the following command in Terminal:

$ echo $PATH

Determine if the/opt/local/bin path is included and ensure that the path is before the/usr/bin path. Otherwise, enter the following command under the home path

$ open-e. Bash_profile

After opening the. bash_profile file, add the following command to the file and save it.

$ export Path=/opt/local/bin: $PATH

Enter the following command to install make, git and GPG packages:

$ posixly_correct=1 sudo port install gmake libsdl git gnupg

The careful user may find the GIT package installed in the command listed above, and the document is using the Git-core package, the author in the actual installation using Git-core will error, change to Git will pass.

5, reduce make version from 3.82 to 3.81
Note: First you need to edit the/opt/local/etc/macports/sources.conf file, which is readable and requires root permission to modify. The modified content is as follows:

At the end of the file, add the following data to the RSYCN line:

File:///Users/Shared/dports

Then you can follow the steps on the official website one command to execute:

$ mkdir/users/shared/dports$ SVN co--revision 50980 http://svn.macports.org/repository/macports/trunk/dports/ devel/gmake/devel/gmake/$ portindex/users/shared/dports$ sudo port install gmake @3.81  

6. Set File description limits

My understanding here is to modify the number of simultaneous open files. Open the. Bash_profile, and add the following code to the file.

# Set the number of open files to be 1024x768ulimit-s-N
The third step, download the original file

In this step, except the 1th dot, is the first call outside (to ensure that the ~/bin folder exists), the other steps in each download source code, need to call, and then call.

1, install repo software (first use, perform this step)

$ mkdir ~/bin$ Curl Https://storage.googleapis.com/git-repo-downloads/repo > ~/bin/repo$ chmod a+x ~/bin/ Repo 

2, mount the disk

Locate the previously created. DMG (new in this article is ANDROID.DMG), and right-click as shown in

Click Diskimagemounter, and the device will be visible at the bottom of the Finder's left column:



3, initialize the repo client

Before you proceed with this procedure, confirm that:

    • After the current directory has been switched to a newly created disk image, after loading, use the CD/VOLUMES/ANDROID_SOURCE_DMG method to switch to the directory.
    • To confirm that your Google account is available, please visit the following URL to confirm: https://accounts.google.com/ServiceLogin
    • Can fq!! At least you can browse Google and Android source code smoothly.

After a few confirmations, you can initialize the client.

First, to create a folder and switch to that folder, such as

$ mkdir android4.0.1$ cd android4.0.1

Second, execute the following command in order to be able to call the repo command successfully:

$ Path=~/bin: $PATH

Then execute the following command:

$ repo init-u https://android.googlesource.com/platform/manifest-b ANDROID-4.0.1_R1

You can modify the version you need to download as needed.

4. Download source code

Execute the following command:

$ repo Sync

So far, the source code should be able to start the download, but because the file is too large, network error or Google IP restrictions and other reasons, during the download process will be a variety of errors or interruptions.

5, download Optimization 1

During the download process, the official website will limit the number of simultaneous connections, in order to solve this problem, the official website provides the following methods:

    • Https://android.googlesource.com/new-password, visit this page, generate the account password, follow the steps of the page, copy the two lines that start the machine in the generated page.
    • Create a new. netrc file under the home path (easy to use with VI).
    • Copy the above copied content to the. netrc file and save it for readability.
    • Initialize the repo client with the following command:
$ repo init-u https://android.googlesource.com/a/platform/manifest-b ANDROID-4.0.1_R1

After you complete the steps above, you can continue with the download.

6, download Optimization 2

Due to network and other reasons, will cause the download interruption, although the user can continue to download through the Repo Sync command, but because the file is too large, the frequency of this situation is very high. So you can use the following command: (from the New Year's Day Android technology core anatomy of a book).

#!/bin/bash   #FileName  get-android.sh  path=~/bin: $PATH   repo init-u https:// Android.googlesource.com/platform/a/manifest-b android-4.0.1_r1           repo sync   while [$? = 1];    echo "================sync failed, Re-sync again =====" sleep 3       

The above file is an executable file (. sh, which is changed by chmod +x get-android.sh) and saved to the download folder path (such as android4.0.1).

Execute the file./get-android.sh, then you can go to sleep.

The next day to turn on the computer, if you see 100% of the logo, and have done the text appear (due to rush to work, no cut chart), more importantly, download the source folder see the various folders, that congratulations, the download succeeded!

Have any questions can leave a message ~

Android source download under Mac

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.