`
isiqi
  • 浏览: 16484532 次
  • 性别: Icon_minigender_1
  • 来自: 济南
社区版块
存档分类
最新评论

Get Android source

阅读更多

Get source

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 Workflow.
  • For reference details about Repo, see Using Repo and Git.

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 (i386)

To set up your Linux development environment, make sure you have the following:

  • Git 1.5.4 or newer and the GNU Privacy Guard.

$ sudo apt-get install git-core gnupg

  • JDK 5.0, update 12 or higher.

$ sudo apt-get install sun-java6-jdk

  • The following packages: flex, bison, gperf, libsdl-dev, libesd0-dev, libwxgtk2.6-dev (optional), build-essential, zip, curl.

$ sudo apt-get install 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

Ubuntu Linux (amd64)

This has not been as well tested. Please send success or failure reports to repo-discuss@googlegroups.com.

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

  • Git, JDK, flex, and the other packages as listed above in the i386 instructions:

$ sudo apt-get install sun-java6-jdk git-core gnupg flex bison gperf build-essential zip curl

  • Pieces from the 32-bit cross-building environment:

$ sudo apt-get install lib32z1-dev gcc-multilib g++-multilib libc6-dev-i386 lib32ncurses5-dev ia32-libs

Other Linux

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

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. The Android build system and tools do not support the obsolete PowerPC architecture.
  • 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.

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 clip_image002[3]. We recommend version 3.0 or newer.
  2. Install MacPorts. To do this:
    1. Download the tar file from http://www.macports.org/ clip_image002[4]and untar the files.
    2. Run the following:
      $ ./configure
      $ make
      $ sudo make install
      $ sudo port selfupdate
    3. View your path:
      $ echo $PATH
      Make sure that /opt/local/bin is in your path before /usr/bin. If not, 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.
  3. Upgrade GNU make to 3.81 or later by running
    $ sudo port install gmake
    $ sudo ln -s gmake /opt/local/bin/make
  4. Install libsdl by running
    $ sudo port install libsdl
  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
  6. Install Git and the GNU Privacy Guard:
    $ sudo port install git-core gnupg
    (You will need Git 1.5.4 or newer.)
  7. Install these optional packages, if you want to:
    $ sudo port install xemacs +sumo
    $ sudo port install gimp

Note: If you get errors from port install, prefix your commands with POSIXLY_CORRECT=1, for example:
$ POSIXLY_CORRECT=1 sudo port install package-name

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 http://android.git.kernel.org/repo >~/bin/repo

$ chmod a+x ~/bin/repo

  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
  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.

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

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 dependancies 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

分享到:
评论

相关推荐

    get android source code

    get android source code

    android get,post获取数据

    在Android中,可以使用`HttpURLConnection`或第三方库如`OkHttp`来实现GET请求。以`HttpURLConnection`为例,创建GET请求的步骤如下: 1. 创建`URL`对象,指定请求的地址。 2. 打开连接,通过`openConnection()`方法...

    download android source code

    下载Android源代码是Android开发中的一个基础步骤,对于理解Android系统的内部运作以及进行自定义修改或构建至关重要。本文将详细讲解在Ubuntu和MacOS系统上下载Android源代码所需的步骤和工具。 首先,确保你的...

    MT6799开发板Android Source code 下载和编译.docx

    source build/envsetup.sh lunch make -j4 ``` `<target_device_name>`应替换为你的设备配置。 **三、编译问题及解决** 在编译过程中可能会遇到错误: 1. **TAREGT_BRM_PLATFORM is undefined** 这个错误...

    基于USB单片机CH559的Android USB通讯设计实例-Android Open Accessory Protocol 2_0 Android Open Source.zip

    本实例探讨了如何使用CH559 USB单片机实现与Android设备的通讯,利用Android Open Accessory Protocol 2.0 (AOA 2.0) 协议进行数据交换。这一技术允许开发人员创建兼容Android系统的外部硬件设备,从而拓展手机或...

    Android-retrofit简单封装实现公共参数get和post统一处理

    在Android开发中,网络编程是不可或缺的一部分,而Retrofit库因其简洁、强大的特性,成为许多开发者首选的HTTP客户端工具。本篇文章将详细讲解如何对Retrofit进行简单的封装,以实现公共参数在GET和POST请求中的统一...

    Android Programming Tutorials, 3rd Edition

    Full source code to all the exercise answers is available, to help you if you get stuck. Android Programming Tutorials makes an excellent companion volume to more traditional Android books that ...

    Hello Android with source code

    Android is a new open source software toolkit for mobile phones that was created by Google and the Open Handset Alliance. In a few years, it’s expected to be found in millions of cell phones and ...

    The Android Developer's Cookbook Building Applications and Source Project

    The Android Developer's Cookbook Building Applications with the Android SDK and Source Project Code 源书(pdf)及源代码12章全都有(rar) Book Description Want to get started building applications for ...

    Android代码-Photo Effects

    Get a clean clone of this project, import the library in Android Studio then Clean and Build the hold project to regenerate the library Then just add library module as a dependency to your existing ...

    android 网络语音搜索 source code

    在这个"android 网络语音搜索 source code"中,我们可以深入学习如何利用`RecogizerIntent`来实现这一功能。 首先,`RecognizerIntent`提供了几种预定义的行动,如`ACTION_RECOGNIZE_SPEECH`,这是用来启动系统内置...

    get-Android-codeinr-windows-.rar_android

    为了方便管理源码,你需要创建一个工作目录,比如"C:\android-source"。在这个目录下,你需要创建几个子目录,如"prebuilts"、"build"、"platforms"等,这些目录在后续的源码拉取过程中会用到。 安装repo工具,它是...

    android访问网络get post 源代码项目

    // <uses-permission android:name="android.permission.INTERNET" /> view sourceprint? 01 //2.需要编写一个服务器servlet代码 02 String userName = request.getParameter("userName"); 03 String password...

    android 9.0 源码下载(28 r6)

    - 创建一个新的工作目录,例如`mkdir android_source && cd android_source` - 初始化Repo:`repo init -u https://android.googlesource.com/platform/manifest -b android-9.0-pie-release` - 下载源码:`repo ...

    Android Read Excel sourcecode

    System.out.print(cell.getContents() + "\t"); } System.out.println(); } workbook.close(); } catch (Exception e) { e.printStackTrace(); } } } ``` 在这个例子中,`Workbook.getWorkbook()`方法...

    Android代码-Android

    go to Android/Android_SourceCode/Android_Learning/bin/ and get the Android_Learning.apk to check out what my app does. or, take a look at the source code activitiesName.java to see. this is still a ...

    android_getCPU_stats_src

    "android_getCPU_stats_src"这个项目可能包含了一些用于获取CPU统计数据的源代码。下面将详细讨论相关知识点。 1. **Proc文件系统**: Linux中的Proc文件系统是一个虚拟文件系统,它提供了查看和修改内核运行时...

Global site tag (gtag.js) - Google Analytics