`

Get source (Android Open Source Project)

阅读更多
What's in the source?
For a description of all the projects that make up the Android source code, see Project layout. To see snapshots and histories of the files available in the public Android repositories, visit the GitWeb web interface.

The source is approximentely 2.1GB in size.  You will need 6GB 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 on recent versions of Ubuntu (6.06 and later), but reports of successes or failures on other distributions are welcome.
Ubuntu Linux (32-bit x86)
To set up your Linux development environment, make sure you have the following:

    * Required Packages:
          o Git 1.5.4 or newer and the GNU Privacy Guard.

          o JDK 5.0, update 12 or higher.  Java 6 is not supported, because of incompatibilities with @Override.

          o flex, bison, gperf, libsdl-dev, libesd0-dev, libwxgtk2.6-dev (optional), build-essential, zip, curl. 

    $ sudo apt-get install git-core gnupg sun-java5-jdk flex bison gperf libsdl-dev libesd0-dev libwxgtk2.6-dev build-essential zip curl libncurses5-dev zlib1g-dev

    * You might also want Valgrind, a tool that will help you find memory leaks, stack corruption, array bounds overflows, etc.

    $ sudo apt-get install valgrind

    * Intrepid (8.10) users may need a newer version of libreadline:

$ sudo apt-get install lib32readline5-dev
Ubuntu Linux (64-bit x86)
This has not been as well tested. Please send success or failure reports to android-porting@googlegroups.com.

The Android build requires a 32-bit build environment as well as some other tools:

    * Required Packages:
          o Git, JDK, flex, and the other packages as listed above in the i386 instructions:
          o JDK 5.0, update 12 or higher.  Java 6 is not supported, because of incompatibilities with @Override.
          o Pieces from the 32-bit cross-building environment
          o X11 development

    $ sudo apt-get install git-core gnupg flex bison gperf build-essential zip curl sun-java5-jdk zlib1g-dev gcc-multilib g++-multilib libc6-dev-i386 lib32ncurses5-dev ia32-libs x11proto-core-dev libx11-dev lib32readline5-dev lib32z-dev

    * Set the system to use the right version of java by default:

      $ sudo update-java-alternatives -s java-1.5.0-sun

    * X11: Ubuntu doesn't have packages for the X11 libraries, but that can be worked around with the following command:

      $ sudo ln -s /usr/lib32/libX11.so.6 /usr/lib32/libX11.so

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

There's no reason why Android cannot be built on non-Ubuntu systems. Please send any success or failure reports to android-porting@googlegroups.com. In general you will need:

    * Python 2.4, which you can download from python.org .
    * JDK 5.0, update 12 or higher, which you can download from java.sun.com . Java 6 is not supported, because of incompatibilities with @Override.
    * Git 1.5.4 or newer. You can find it at http://git.or.cz/ .

Anything missing from this list? Please let us know!

Mac OS

Requirements:

    * To build the Android files in a Mac OS environment, you need an Intel/x86 machine running MacOS 10.4 ("Tiger") or 10.5 ("Leopard"). At the moment MacOS 10.6 ("Snow Leopard") is not supported. The Android build system and tools do not support the obsolete PowerPC architecture.
    * Android must be built on a case-sensitive file system.
          o We recommend that you build Android on a partition that has been formatted with the "Case-sensitive Journaled HFS+" file system:
                + A case-sensitive file system is required because the sources contain files that differ only in case.
                + Journaled systems are more robust. (This is optional, but recommended.)
                + HFS+ is required to successfully build Mac OS applications such as the Android Emulator for OS X.
          o If you want to avoid partitioning/formatting your hard drive, you can use a case-sensitive disk image instead.
                + To create the image:
                      # launch /Applications/Utilities/Disk Utility
                      # select "New Image"
                      # size: 8 GB (this will work, but you can choose more if you want to)
                      # volume format: case sensitive, journaled
                + This will create a .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":

                  # command to 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 would with an external drive.

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

   1. Install the XCode version 2.4 or later from http://developer.apple.com . We recommend version 3.0 or newer.
   2. Install MacPorts. To do this:
         1. Download the tar file from http://www.macports.org/ and untar the files.
         2. Run the following:
              $ ./configure
              $ make
              $ sudo make install
         3. Make sure that /opt/local/bin is in your path before /usr/bin. by running
                $ echo $PATH
            If you don't see /opt/local/bin, edit $HOME/.bash_profile and add the line
              export PATH=/opt/local/bin:$PATH
            (or the equivalent for other shells) after any other PATH-related lines. To verify that your path is now correct, open a new terminal and run echo $PATH again.
         4. Ask MacPorts to update itself:
              $ sudo port selfupdate
   3. Get the following packages from port:
        $ POSIXLY_CORRECT=1 sudo port install gmake libsdl git-core gnupg
      If using Mac OS 10.4, also install:
        $ POSIXLY_CORRECT=1 sudo port install bison
   4. Upgrade GNU make to 3.81 or later by running.  Mac OS doesn't come with a recent enough version.
        $ sudo ln -s gmake /opt/local/bin/make
   5. Set an appropriate per-process file descriptor limit. To do this, add the following lines to your .bash_profile file:
         # 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 check to be sure that this bin directory is in your path:
        $ cd ~
        $ mkdir bin
        $ echo $PATH
   2. Download the repo script and make sure it is executable:
      $ curl https://android.git.kernel.org/repo >~/bin/repo
      $ chmod a+x ~/bin/repo


Initializing a Repo client

   1. Create an empty directory to hold your working files:
      $ mkdir mydroid
      $ cd mydroid
   2. Run repo init to bring down the latest version of Repo with all its most recent bug fixes. You must specify a URL for the manifest:
      $ repo init -u git://android.git.kernel.org/platform/manifest.git
          * If you would like to check out a branch other than "master", specify it with -b, like:
            $ repo init -u git://android.git.kernel.org/platform/manifest.git -b cupcake
   3. When prompted, configure Repo with your real name and email address. If you plan to submit code, use an email address that is associated with a Google account.

A successful initialization will end with a message such as
   repo initialized in /mydroid

Your client directory should now contain a .repo directory where files such as the manifest will be kept.

What will my name and email be used for?

To use the Gerrit code-review tool, you will need an email address that is connected with a registered Google account (which does not have to be a Gmail address). Make sure this is a live address at which you can receive messages. The real name that you provide here will show up in attributions for your code submissions.

What is a manifest file?

The Android source files are divided among a number of different repositories. A manifest file contains a mapping of where the files from these repositories will be placed within your working directory when you synchronize your files.


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 about repo 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

then paste the key(s) below, and press Control-D to end the input and process the keys.  After importing the keys, you can verify any tag with

   $ git tag -v tagname

key 9AB10E78: "The Android Open Source Project <initial-contribution@android.com>"

-----BEGIN PGP PUBLIC KEY BLOCK-----
Version: GnuPG v1.4.2.2 (GNU/Linux)

mQGiBEnnWD4RBACt9/h4v9xnnGDou13y3dvOx6/t43LPPIxeJ8eX9WB+8LLuROSV
lFhpHawsVAcFlmi7f7jdSRF+OvtZL9ShPKdLfwBJMNkU66/TZmPewS4m782ndtw7
8tR1cXb197Ob8kOfQB3A9yk2XZ4ei4ZC3i6wVdqHLRxABdncwu5hOF9KXwCgkxMD
u4PVgChaAJzTYJ1EG+UYBIUEAJmfearb0qRAN7dEoff0FeXsEaUA6U90sEoVks0Z
wNj96SA8BL+a1OoEUUfpMhiHyLuQSftxisJxTh+2QclzDviDyaTrkANjdYY7p2cq
/HMdOY7LJlHaqtXmZxXjjtw5Uc2QG8UY8aziU3IE9nTjSwCXeJnuyvoizl9/I1S5
jU5SA/9WwIps4SC84ielIXiGWEqq6i6/sk4I9q1YemZF2XVVKnmI1F4iCMtNKsR4
MGSa1gA8s4iQbsKNWPgp7M3a51JCVCu6l/8zTpA+uUGapw4tWCp4o0dpIvDPBEa9
b/aF/ygcR8mh5hgUfpF9IpXdknOsbKCvM9lSSfRciETykZc4wrRCVGhlIEFuZHJv
aWQgT3BlbiBTb3VyY2UgUHJvamVjdCA8aW5pdGlhbC1jb250cmlidXRpb25AYW5k
cm9pZC5jb20+iGAEExECACAFAknnWD4CGwMGCwkIBwMCBBUCCAMEFgIDAQIeAQIX
gAAKCRDorT+BmrEOeNr+AJ42Xy6tEW7r3KzrJxnRX8mij9z8tgCdFfQYiHpYngkI
2t09Ed+9Bm4gmEO5Ag0ESedYRBAIAKVW1JcMBWvV/0Bo9WiByJ9WJ5swMN36/vAl
QN4mWRhfzDOk/Rosdb0csAO/l8Kz0gKQPOfObtyYjvI8JMC3rmi+LIvSUT9806Up
hisyEmmHv6U8gUb/xHLIanXGxwhYzjgeuAXVCsv+EvoPIHbY4L/KvP5x+oCJIDbk
C2b1TvVk9PryzmE4BPIQL/NtgR1oLWm/uWR9zRUFtBnE411aMAN3qnAHBBMZzKMX
LWBGWE0znfRrnczI5p49i2YZJAjyX1P2WzmScK49CV82dzLo71MnrF6fj+Udtb5+
OgTg7Cow+8PRaTkJEW5Y2JIZpnRUq0CYxAmHYX79EMKHDSThf/8AAwUIAJPWsB/M
pK+KMs/s3r6nJrnYLTfdZhtmQXimpoDMJg1zxmL8UfNUKiQZ6esoAWtDgpqt7Y7s
KZ8laHRARonte394hidZzM5nb6hQvpPjt2OlPRsyqVxw4c/KsjADtAuKW9/d8phb
N8bTyOJo856qg4oOEzKG9eeF7oaZTYBy33BTL0408sEBxiMior6b8LrZrAhkqDjA
vUXRwm/fFKgpsOysxC6xi553CxBUCH2omNV6Ka1LNMwzSp9ILz8jEGqmUtkBszwo
G1S8fXgE0Lq3cdDM/GJ4QXP/p6LiwNF99faDMTV3+2SAOGvytOX6KjKVzKOSsfJQ
hN0DlsIw8hqJc0WISQQYEQIACQUCSedYRAIbDAAKCRDorT+BmrEOeCUOAJ9qmR0l
EXzeoxcdoafxqf6gZlJZlACgkWF7wi2YLW3Oa+jv2QSTlrx4KLM=
=Wi5D
-----END PGP PUBLIC KEY BLOCK-----


Building the code
To build the files, run make from within your working directory:
    $ cd ~/mydroid
    $ make

If your build fails, complaining about a missing "run-java-tool", try setting the ANDROID_JAVA_HOME env var to $JAVA_HOME before making.  E.g.,

    $ export ANDROID_JAVA_HOME=$JAVA_HOME
Using an IDE

    * Using Eclipse for Android platform development

Troubleshooting

ImportError: No module named readline

Mac users getting this should install Python 2.5.2. 

Linux users that installed Python from source, make sure the dependencies for libreadline are installed, and rebuild Python.
What's next?
To learn about reporting an issue and searching previously 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/download
分享到:
评论

相关推荐

    Android google io 2012 opensource已通过编译无错误

    This project is the Android app for the conference. The app supports devices running Android 2.2+, and is optimized for phones and tablets of all shapes and sizes. With the app, users can: View the ...

    zoo-project-1.5.0.tar.bz2

    ZOO-Project is a WPS (Web Processing Service) open source project released under a MIT/X-11 style license . It provides an OGC WPS compliant developer-friendly framework to create and chain WPS Web ...

    source insight linux安装版本

    通过菜单栏的"File" -&gt; "Open Project",选择你的源代码根目录。Source Insight会自动扫描并加载代码文件。你可以设置自定义的快捷键、代码风格和偏好设置,以适应个人的工作习惯。 Source Insight的强大之处在于它...

    android 9.0 源码下载(28 r6)

    - **AOSP(Android Open Source Project)**:Android开源项目,包含了Android系统的全部开源代码。 - **版本代号**:Android 9.0 Pie的内部版本号为28,r6表示第六个发布候选版本。 5. **简书文章链接** 提供的...

    Android代码-focus-android

    We encourage you to participate in this open source project. We love Pull Requests, Bug Reports, ideas, (security) code reviews or any kind of positive contribution. Please read the Co

    Android-Terminal-Emulator.zip

    Android Terminal Emulator is an open source project. Well written patches to fix bugs or add new features are welcome! Quick FAQ: This isn't a game emulator. This won't help you root your phone or ...

    Ubuntu系统下Android源码编译.pdf

    Android源码主要托管在GitHub的AOSP(Android Open-Source Project)仓库中。开发者需要使用Git克隆源码到本地,通常命令为`git clone https://github.com/aosp-mirror/platform_manifest.git`。此外,还需要设置...

    source insight中汉字改进与函数调用关系设置

    1. 打开 Project→Open Project→base,新建一个 SuperBackSpace.em 文件。 2. 将以下代码加入到 SuperBackSpace.em 文件中: ``` /macro SuperBackspace(){ hwnd = GetCurrentWnd(); hbuf = GetCurrentBuf(); ...

    Gradle Recipes for Android(O'Reilly,2016)

    Android adopted Gradle as the preferred build automation system a few years ago, but many Android developers are still unfamiliar with this open source tool. This hands-on guide provides a collection ...

    Android 开发 — 开机自启动

    ACTION_BOOT_COMPLETED广播在SystemServer启动后由BroadcastQueue发送,你可以通过阅读AOSP(Android Open Source Project)源码了解更多细节。 对于开发工具,例如Android Studio,它提供了调试BroadcastReceiver...

    Android代码-plog

    plog Fire and forget unboxed or fragmented messages over UDP or TCP, have them forwarded to Kafka 0.8 or the standard output. That should cover syslog.... opensource@airbnb.com Getting started $ printf '

    Android_4.2_源码下载和编译环境安装及Android_4.2_源码编译

    Android源码通常存储在GitHub的AOSP(Android Open Source Project)仓库中。对于Android 4.2,命令可能是: ``` git clone https://android.googlesource.com/platform/manifest -b android-4.2 ``` - 这个过程...

    Bullet Physics For Unity.unitypackage

    Wanting more flexibility than I could get using PhysX, I started this Unity port of the open source BulletSharp project. Bullet Physics is compiled as a native plugin and accessed from unity scripts ...

    Android键盘 AOSP监听delete按键

    在Android系统中,Android键盘(AOSP,Android Open Source Project)是用户与设备进行交互的重要组成部分,特别是对于输入文本的应用场景。在某些情况下,开发者可能需要对键盘的行为进行自定义,比如监听特定按键...

    Android代码-可定制的UI组件的开源框架

    Atlas is an open source framework of customizable UI components for use with the Layer SDK designed to get messaging tested and integrated quickly. This repository contains the Atlas library. For a ...

    Android环境选择目录文件的代码

    - `gen`: 生成的R类和其他自动生成代码的目录,现在由`build/generated/source/r`取代。 - `.settings`: Eclipse项目特定设置的目录。 总的来说,这个代码示例涵盖了Android应用中选择和操作目录的基本流程,以及一...

    快速搭建android5-1系统源码编译环境.pdf

    2. **克隆源码**:使用Git从AOSP(Android Open Source Project)仓库拉取源码。创建一个目录用于存放源码,然后执行: ```bash mkdir -p ~/android-source cd ~/android-source repo init -u ...

    Android 轻松实现语音识别的完整代码

    /* Copyright(C)2008 The Android Open Source Project * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may ...

Global site tag (gtag.js) - Google Analytics