`
mmdev
  • 浏览: 12925478 次
  • 性别: Icon_minigender_1
  • 来自: 大连
文章分类
社区版块
存档分类
最新评论

Android移动操作系统源代码

 
阅读更多

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:

What's in the source?

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

The source is approximately 2.6GB 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 in house on recent versions of Ubuntu (10.04 and later), but most distributions should 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 frompython.org .
  • JDK 6 if you wish to build Gingerbread or newer; JDK 5 for Froyo or older. You can download either fromjava.sun.com .
  • Git 1.5.4 or newer. You can find it athttp://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 should 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 corruption, 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.5GB of RAM and 10GB 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 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":

# 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 XCode fromhttp://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 fromhttp://www.macports.org/ .
  3. Make sure that /opt/local/bin appears in your path BEFORE /usr/bin. If not, add
    export 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 with
    $ 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, seeUsing 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 included 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 various repositories included 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 should now contain a.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, seeUsing 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+8LLuROSV
lFhpHawsVAcFlmi7f7jdSRF+OvtZL9ShPKdLfwBJMNkU66/TZmPewS4m782ndtw7
8t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xmL8UfNUKiQZ6esoAWtDgpqt7Y7s
KZ8laHRARonte394hidZzM5nb6hQvpPjt2OlPRsyqVxw4c/KsjADtAuKW9/d8phb
N8bTyOJo856qg4oOEzKG9eeF7oaZTYBy33BTL0408sEBxiMior6b8LrZrAhkqDjA
vUXRwm/fFKgpsOysxC6xi553CxBUCH2omNV6Ka1LNMwzSp9ILz8jEGqmUtkBszwo
G1S8fXgE0Lq3cdDM/GJ4QXP/p6LiwNF99faDMTV3+2SAOGvytOX6KjKVzKOSsfJQ
hN0DlsIw8hqJc0WISQQYEQIACQUCSedYRAIbDAAKCRDorT+BmrEOeCUOAJ9qmR0l
EXzeoxcdoafxqf6gZlJZlACgkWF7wi2YLW3Oa+jv2QSTlrx4KLM=
=Wi5D
-----END PGP PUBLIC KEY BLOCK-----
After importing the keys, you can verify any tag with
$ git tag -vtagname

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 setting theANDROID_JAVA_HOME environment variable before making.
$ export ANDROID_JAVA_HOME=$JAVA_HOME

What's next?

SeeUsing Eclipse for instructions on how to use an IDE for Android platform development. To learn about reporting an issue and searching previously reported issues, seeReport bugs . For information about editing the files and uploading changes to the code-review server, seeContribute .

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

分享到:
评论

相关推荐

    Android移动操作系统源代码指南

    可根据指南提示,应用并开发Android程序。

    Android高级编程--源代码

    该资料是《Android高级编程》的源代码 对应的书籍资料见: Android高级编程 基本信息 原书名: Professional Android Application Development 原出版社: Wrox 作者: (英)Reto Meier 译者: 王鹏杰 霍建同 出版社...

    基于Android平台的移动学习系统的设计与实现(源码+文档).zip

    在市场上成熟的智能手机操作系统中,Android内核基于Linux平台,有着较快的处理速度和较好的系统性能,使用平台无关的Java语言作为其开发语言,可移植性好,可以广泛支持智能手机、平板电脑等移动设备,是移动学习...

    毕业设计基于Android的移动音乐App播放系统项目源码.zip

    毕业设计基于Android的移动音乐App播放系统项目源码毕业设计基于Android的移动音乐App播放系统项目源码毕业设计基于Android的移动音乐App播放系统项目源码毕业设计基于Android的移动音乐App播放系统项目源码毕业设计...

    Android入门到精通源代码.

    1.1.1 移动信息设备分类 1.1.2 Open Handset Alliance和 Android 1.2 Android简介 1.2.1 Andriod的历史 1.2.2 Andriod的未来 1.2.3 Andriod平台的技术架构 1.3 Android应用程序构成 1.3.1 活动(Activity) 1.3.2 ...

    国产操作系统简介.pptx

    Android也是一种基于Linux的自由及开放源代码的操作系统,主要使用于移动设备,如智能手机和平板电脑。大家熟悉的小米MIUI操作系统,阿里的Yun Os和魅族的Flyme OS等都是基于Android二次开发的国产移动终端操作系统...

    Android移动应用开发从入门到精通[PDF+源代码]

    《Android移动应用开发从入门到精通》由浅入深地全面讲解了基于Android系统的软件开发,以Andmid 2.3版本作为主要的SDK版本。本书涉及面广,涵盖了Android系统几乎所有的应用领域,并详细介绍了Android系统常用工具...

    Android系统源代码情景分析.zip

    操作系统:LInux、IOS、树莓派、安卓开发、微机操作系统、网络操作系统、分布式操作系统等。此外,还有嵌入式操作系统、智能操作系统等。 网络与通信:数据传输、信号处理、网络协议、网络与通信硬件、网络安全网络...

    基于java开发小区停车APP管理系统源代码.rar

    本设计阐述了在Android平台下小区停车APP管理系统的设计与实现过程,其目的是让用户能够在Android平台的移动设备上开始实现搜索停车场、导航,进行车位预约的功能。小区停车APP管理系统采用MVC软件开发模式,使用...

    android系统源代码情景分析,基于android2.3.1.zip

    操作系统:LInux、IOS、树莓派、安卓开发、微机操作系统、网络操作系统、分布式操作系统等。此外,还有嵌入式操作系统、智能操作系统等。 网络与通信:数据传输、信号处理、网络协议、网络与通信硬件、网络安全网络...

    基于安卓Android的校园APP系统设计(源码+论文)(MySQL)(含录像).rar

    随着智能手机的大量普及, Android操作系统市场因此风生水起。如何使智能手机用户,能够随时随地查询互联网的服务,其中一方法就是将应用系统功能拓展至手机上,使得手机终端能够通过移动网以和互联网来访问Web站点...

    论文研究-基于源代码静态分析技术的Android应用恶意行为检测模型 .pdf

    基于源代码静态分析技术的Android应用恶意行为检测模型,路程,张淼,目前,基于Linux内核的Android移动终端操作系统面临着大量恶意软件的安全威胁。本文提出一种基于静态分析技术的Android应用恶意行为检��

    Android增量更新项目源代码。带C源程序以及ndk编译好的so包。可以直接导出使用。.zip

    操作系统:LInux、树莓派、安卓开发、微机操作系统、网络操作系统、分布式操作系统等。此外,还有嵌入式操作系统、智能操作系统等。 网络与通信:数据传输、信号处理、网络协议、网络与通信硬件、网络安全网络与通信...

    安卓Android编程视频, 安卓代码大全, 安卓开发系列视频, 移动开发教程

    Android 是一个开源的,基于 Linux 的移动设备操作系统,如智能手机和平板电脑。Android 是由谷歌及其他公司带领的开放手机联盟开发的。 Android 提供了一个统一的应用程序开发方法,这意味着开发人员只需要为 ...

    Android移动应用开发(第3版)卷Ⅰ基础篇 (Shane Conder, Lauren Darcey) PDF扫描版

    C.1.1 集成源代码管理服务  C.1.2 调整视图中的标签面板  C.1.3 最大化窗口  C.1.4 最小化窗口  C.1.5 显示并排窗口  C.1.6 显示同一文件的两个部分  C.1.7 关掉不需要的标签面板  C.1.8 保持对窗口...

    恶意软件检测系统Android端代码.zip

    1. 开放源代码:Android 是基于 Linux 内核的开源操作系统,开发人员可以自由获取、使用和修改源代码。 2. 多样化的硬件设备支持:Android 支持多种硬件设备和屏幕尺寸,可以运行于手机、平板电脑、电视、手表等多种...

    铁路压实系统移动客户端(Android).zip

    1. 开放源代码:Android 是基于 Linux 内核的开源操作系统,开发人员可以自由获取、使用和修改源代码。 2. 多样化的硬件设备支持:Android 支持多种硬件设备和屏幕尺寸,可以运行于手机、平板电脑、电视、手表等多种...

    Android移动终端平台下NFC技术移动签到管理系统的设计研究

    鉴于当前NFC技术在推动移动签到发展中的重要性,本篇设计实现基于Android移动终端平台下NFC技术的移动签到管理系统,以便从而使系统用户可以通过简便地操作手机,就可以完成签到管理过程。结果证实,基于Android移动...

    移动医疗终端系统源码.zip

    移动医疗终端系统源码是一个基于Android的移动医疗终端系统,由Android手机端应用软件和硬件测量设备构成,主要面向居家养老的老年群体心脑血管疾病、糖尿病监测和健康护理方面。使用本系统可以足不出户,居家方便...

    基于Android的智能招聘系统的移动端代码.zip

    1. 开放源代码:Android 是基于 Linux 内核的开源操作系统,开发人员可以自由获取、使用和修改源代码。 2. 多样化的硬件设备支持:Android 支持多种硬件设备和屏幕尺寸,可以运行于手机、平板电脑、电视、手表等多种...

Global site tag (gtag.js) - Google Analytics