Android mobile OS source code

Source: Internet
Author: User
Tags gnupg
Document directory
  • Linux
  • Mac OS X

 

Get Android source code

This document describes how to set up your local work environment, how to use repo to get the android files, and how to build the files on your machine.

Related reading:

  • For an overview of the entire code-Review and code-update process, see life of a patch
    .
  • For reference details About Repo, see using repo and git
    .

 

What's in the source?

To see snapshots and histories of the files available in the public Android repositories, visit the gitweb
Web interface.

The source is approximately 2.6 GB in size. You will need 6 GB free to complete the build.

Setting up your machine

To build the android source files, you will need to use Linux or Mac OS. Building under windows is not currently supported.

Linux

The android build is routinely tested in house on recent versions of ubuntu (10.04 and later), but most distributions shocould have the required build tools available. reports of successes or failures on other distributions are welcome.

In general you will need:

  • Python 2.4, which you can download from python.org
    .
  • JDK 6 if you wish to build gingerbread or newer; JDK 5 for froyo or older. You can download either from java.sun.com
    .
  • Git 1.5.4 or newer. You can find it at http://git.or.cz/
    .

 

Ubuntu Linux (64-bit)

The Sun JDK is no longer in Ubuntu's main package repository. In order to download it, you need to add the appropriate repository and indicate to the system which JDK shoshould be used.

Java 6: For gingerbread and newer

Sudo add-Apt-repository "Deb http://archive.canonical.com/lucid partner"
Sudo add-Apt-repository "Deb-Src http://archive.canonical.com/ubuntu lucid partner"
Sudo apt-Get update
Sudo apt-Get install sun-java6-jdk
Sudo Update-Java-alternatives-s Java-6-sun

 

Java 5: for froyo and older

Sudo add-Apt-repository "Deb http://archive.ubuntu.com/ubuntu dapper main Multiverse"
Sudo add-Apt-repository "Deb http://archive.ubuntu.com/ubuntu dapper-Updates main Multiverse"
Sudo apt-Get update
Sudo apt-Get install sun-java5-jdk
Sudo Update-Java-alternatives-s Java-1.5.0-sun

 

 

To set up your development environment, install the following required packages:

$ Sudo apt-Get install Git-core GnuPG flex bison gperf build-essential zip curl zlib1g-dev gcc-multilib g ++-multilib libc6-dev-i386 lib32ncurses5-dev ia32-libs x11proto-core-dev libx11-dev lib32readline5-dev lib32z-dev

 

You might also want valgrind, a tool that will help you find memory leaks, stack rollback uption, Array Bounds overflows, etc.

Running Linux in a virtual machine

If you are running Linux in a virtual machine, you will need at least 1.5 GB of Ram and 10 Gb or more of disk space in order to build the android tree.

Mac OS X

To build the android files in a Mac OS environment, you need an Intel/x86 machine running MACOs 10.4 (TIGER), 10.5 (Leopard), or 10.6 (snow leopard ). the android build system and tools do not support the obsolete PowerPC architecture.

Android must be built on a case-sensitive file system because the sources contain files that differ only in case. we recommend that you build android on a partition that has been formatted with the journaled File System HFS +. HFS + is required to successfully build Mac OS applications such as the android emulator for OS X.

Creating a case sensitive disk image

If you want to avoid partitioning/formatting your hard drive, you can use a case-sensitive disk image instead. to create the image, launch Disk Utility and select "New Image ". A size of 8 GB is sufficient, or more if you prefer. be sure to select "case sensitive, journaled" as the volume format.

This will create. DMG file which, once mounted, acts as a drive with the required formatting for Android development. for a disk image named "android. DMG "stored in your home directory, you can add the following to your~ /. Bash_profile
To mount the image when you execute "mountandroid ":

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

Once mounted, you'll do all your work in the "android" volume. You can eject it (unmount it) Just like you wocould with an external drive.

 

To set up your Mac OS development environment, follow these steps:

  1. Install xcode from http://developer.apple.com
    . We recommend version 3.0 or newer. If you are not already registered as an apple developer, you will have to create an Apple id in order to download.
  2. Install macports from http://www.macports.org/
    .
  3. Make sure that/opt/local/bin appears in your path before/usr/bin. If not, addexport Path =/opt/local/bin: $ path

    To your~ /. Bash_profile
    .

  4. Get make, git, and GPG packages from Port: $ posixly_correct = 1 sudo port install gmake libsdl Git-core GnuPG

    If using Mac OS 10.4, also install bison:

    $ Posixly_correct = 1 sudo port install bison
  5. Temporary step: There is a bug in gmake 3.82 that prevents android from building. You can install version 3.81 using macports by taking the following steps:

    Edit/Opt/local/etc/macports/sources. conf
    And a line that says

    File: // users/shared/dports

    Above the rsync line. Then create this directory:

    $ Mkdir/users/shared/dports

    In the newDports
    Directory, run

    $ SVN co -- Revision 50980 http://svn.macports.org/repository/macports/trunk/dports/devel/gmake/ devel/gmake/

    Create a port index for your new local repository:

    $ Portindex/users/shared/dports

    Finally, install the old version of gmake

    $ Sudo port install gmake @ 3.81

     

  6. Set an appropriate per-process file descriptor limit. To do this, add the following lines to your~ /. Bash_profile
    :

    # Set the number of open files to be 1024
    Ulimit-S-n 1024

 

Installing Repo

Repo is a tool that makes it easier to work with git in the context of Android. For more information about repo, see using repo and git
.

To install, initialize, and configure Repo, follow these steps:

  1. Make sure you have a bin/directory in your home directory, and that it is stored in your path:

    $ Mkdir ~ /Bin
    $ Path = ~ /Bin: $ path
  2. Download the repo script and ensure it is executable: $ curl http://android.git.kernel.org/repo> ~ /Bin/Repo
    $ Chmod A + x ~ /Bin/Repo
Initializing a repo Client

After installing Repo, set up your client to access the android source Repository:

  1. Create an empty directory to hold your working files:

    $ MkdirDirectory

    $ CdDirectory
  2. RunRepo init
    To bring down the latest version of Repo with all its most recent bug fixes. you must specify a URL for the manifest, which specifies where the varous repositories has been in the android source will be placed within your working directory.

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

    To check out a branch other than "master", specify it with-B:

    $ Repo init-u git: // android.git.kernel.org/platform/manifest.git-B cupcake
  3. When prompted, Please configure repo with your real name and email address. To use the Gerrit code-review tool, you will need an email address that is connected with aregistered Google account
    . Make sure this is a live address at which you can receive messages. The name that you provide here will show up in attributions for your code submissions.

A successful initialization will end with a message stating that repo is initialized in your working directory. Your client directory shocould now contain. Repo
Directory where files such as the manifest will be kept.

 

Getting the files

To pull down files to your working directory from the repositories as specified in the default manifest, run

$ Repo sync

For more aboutRepo sync
And other repo commands, see using repo and git
.

The android source files will be located in your working directory under their project names.

Verifying git tags

Load the following public key into your GnuPG key database. The key is used to sign annotated tags that represent releases.

$ GPG -- Import

Copy and paste the key (s) below, then enter EOF (CTRL-d) to end the input and process the keys.

----- Begin PGP Public Key Block -----
Version: GnuPG v1.4.2.2 (GNU/Linux)

Mqgibennwd4rbact9/h4v9xnngdou13y3dvox6/t43lppixej8ex9wb + 8 llurosv
Lfhphawsvacflmi7f7jdsrf + ovtzl9shpkdlfwbjmnku66/tzmpews4m782ndtw7
Bytes
U4pvgchaajztyj1eg + uybiueajmfearb0qran7deoff0fexseaua6u90seovks0z
Wnj96sa8bl + a1ooeuufpmhihyluqsftxisjxth + 2qclzdvidyatrkanjdyy7p2cq
/Release/i1s5
Ju5sa/9wwips4sc84ielixigweqq6i6/sk4i9q1yemzf2xvvknmi1f4icmtnksr4
Mgsa1ga8s4iqbsknwpgp7m3a51jcvcu6l/8 ztpa + uugapw4twcp4o0dpivdpbea9
B/AF/ygcr8mh5hgufpf9ipxdknosbkcvm9lssfrcietykzc4wrrcvghliefuzhjv
Bytes
Cm9pzc5jb20 + igaeexecacafaknnwd4cgwmgcwkibwmcbbuccamefgidaqieaqix
Gaakcrdort + bmreoenr + aj42xy6tew7r3kzrjxnrx8mij9z8tgcdffqyihpyngki
2t09ed + 9bm4gmeo5ag0esedyr1_akvw1jcmbwvv/0bo9wibyj9wj5swmn36/Val
Qn4mwrhfzdok/rosdb0csao/l8kz0gkqpofobtyyjvi8jmc3rmi + livsut9806up
Hisyemmhv6u8gub/xhlianxgxwhyzjgeuaxvcsv + evopihby4l/kvp5x + ocjidbk
C2b1tvvk9pryzme4bpiql/ntgr1olwm/uwr9zruftbne411aman3qnahbbmzzkmx
Lwbgwe0znfrrnczi5p49i2yzjajyx1p2wzmsck49cv82dzlo71mnrf6fj + udtb5 +
Ogtg7cow + 8pratkjew5y2jizpnruq0cyxamhyx79emkhdsthf/8 aawuiajpwsb/m
PK + kms/s3r6njrnyltfdzhtmqximpodmjg1zxml8ufnukiqz6esoawtdgpqt7y7s
Kz8lahraronte394hidzzm5nb6hqvppjt2olprsyqvxw4c/ksjadtaukw9/d8phb
Bytes
Vuxrwm/ffkgpsoysxc6xi553cxbuch2omnv6ka1lnmwzsp9ilz8jegqmutkbszwo
G1s8fxge0lq3cddm/gj4qxp/p6liwnf99fadmtv3 + 2saogvytox6kjkvzkossfjq
Hn0dlsiw8hqjc0wisqqyeqiacqucsedyraibdaakcrdort + bmreoecuoaj9qmr0l
Exzeoxcdoafx4156gzljzlacgkwf7wi2ylw3oa + jv2qstlrx4klm =
= Wi5d
----- End PGP Public Key Block -----

After importing the keys, you can verify any tag

$ Git tag-V Tagname

 

Building the code

To build the files, run envsetup, lunch, And make from within your working directory:

$ Cd ~ / Directory

$ Source build/envsetup. Sh
$ Lunch
$ Make

If your build fails because of a missingRun-Java-Tool
, Try settingAndroid_java_home
Environment Variable before making.

$ Export android_java_home = $ java_home

 

What's next?

See using eclipse
For instructions on how to use an IDE for Android platform development. To learn about reporting an issue and searching previusly reported issues, see Report Bugs
. For information about editing the files and uploading changes to the Code-review server, see contribute
.

 

Http://source.android.com/source/download.html

 

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.