为了编译安卓源码,首先需要一个Linux,本次采用Ubuntu Kylin14.04,内核版本3.13。装在四核、4G内存、1T硬盘的虚拟机上
查看内核版本号:
$uname -all
清华镜像地址
清华镜像站的速度还是比较快的,地址:
git://aosp.tuna.tsinghua.edu.cn/android/
使用浏览器访问:
http://aosp.tuna.tsinghua.edu.cn/android/

下载 repo
$git clone git://aosp.tuna.tsinghua.edu.cn/Android/git-repo.git/

修改repo
$vi /git-repo.git/repo
google的地址
REPO_URL = ‘https://gerrit.googlesource.com/git-repo’
改为清华大学的地址
REPO_URL = ‘git://aosp.tuna.tsinghua.edu.cn/android/git-repo’

下载 manifest
google 的地址
$ repo init -u https://android.googlesource.com/platform/manifest
改为清华大学的地址
$ repo init -u git://aosp.tuna.tsinghua.edu.cn/android/platform/manifest
如果需要设置版本,加入参数-b 安卓源码版本号即可。
$ repo init -u https://aosp.tuna.tsinghua.edu.cn/platform/manifest -b android-4.0.1_r1

同步源码
$repo sync [-j4]
后面-j4表示4个线程进行下载,清华镜像允许最多4线程下载,不要超过4个。
如果中间发现断掉了或者报错了,不要紧张,重新运行一下。源码大小

Set up environment(设置环境变量)

Initialize the environment with the envsetup.sh script. Note that replacing source with . (a single dot) saves a few characters, and the short form is more commonly used in
documentation.
$ source build/envsetup.sh or $ . build/envsetup.sh

Choose a Target(选择平台编译)

Choose which target to build with lunch. The exact configuration can be passed as an argument. For example, the following command:$ lunch aosp_arm-eng

refers to a complete build for the emulator, with all debugging enabled.

If run with no arguments lunch will prompt you to choose a target from the menu.

All build targets take the form BUILD-BUILDTYPE, where the BUILD is a codename referring to the particular feature combination.

The BUILDTYPE is one of the following:


Build the code(构建代码)

Build everything with make. GNU make can handle parallel tasks with a -jN argument, and it's common to use a number of tasks N that's between 1 and 2 times the number of

hardware threads on the computer being used for the build. For example, on a dual-E5520 machine (2 CPUs, 4 cores per CPU, 2 threads per core), the fastest builds are made

with commands between make -j16 and make -j32.

$ make -j4

最后运行我们刚刚编译出来的android系统Run It!

You can either run your build on an emulator or flash it on a device. Please note that you have already selected your build target with lunch, and it is unlikely at best to
run on a different target than it was built for.

Flash a Device(烧进一个真实的设备)

To flash a device, you will need to use fastboot, which should be included in your path after a successful build. Place the device in fastboot mode either manually by holding

the appropriate key combination at boot, or from the shell with

$ adb reboot bootloader

Once the device is in fastboot mode, run

$ fastboot flashall -w

The -w option wipes the /data partition on the device; this is useful for your first time flashing a particular device but is otherwise unnecessary.

For more information about building for and running on actual hardware, see Running Builds.

Emulate an Android Device(模拟一个安卓设备)

The emulator is added to your path automatically by the build process. To run the emulator, type

emulator模拟器能成功运行起来的前提是:成功将emulator所在的目录和 android编译完之后输出目录out下面的host和target目录都添加到了你的PATH环境变量了。
并且执行source build/envsetup.sh ;lunch sdk-eng;这2个命令。

$ emulator

利用国内镜像下载Android源码,并编译生成image镜像文件的更多相关文章

  1. 通过清华大学镜像下载Android源码并编译源码

    之前看源码都是在Windows下用SourceInsight看,虽然达到了研究源码的效果,但终究还是有遗憾...趁着周末,准备在Ubuntu虚拟机上下载编译源码. 之前下源码时,有了解一些Androi ...

  2. [Android] repo 下载Android源码(国内镜像)

    reference : http://blog.csdn.net/shenlan18446744/article/details/51490560 repo 下载Android源码(国内镜像) 下载r ...

  3. 下载android源码

    http://source.android.com Step 1.按照http://source.android.com/source/initializing.html配置好android编译环境 ...

  4. 【Linux/Ubuntu学习6】unbuntu 下载android源码

    在Windows下安装Cygwin,通过Cygwin也可在Windows里通过本文的下载步骤下载Android源码. 以下为在Ubuntu下下载Google Android4.4源码的步骤: 1. 安 ...

  5. Windows平台下载Android源码(整理)

    Google官方下载源码使用的系统Ubuntu系统,不过现在我们需要在Windows系统中下载Android源码文件. 网站的地址是:https://android.googlesource.com/ ...

  6. (国内)完美下载Android源码Ubuntu版

    今天写的文章莫名奇妙的没了,所以再重新写一篇. 首先,为了方便起见,我已经将系统更换成里Ubuntu,因为官方推荐使用这个Linux发行版.先来一张系统的截图: Ubuntu的版本是16.04(推荐用 ...

  7. 快速下载android源码

    众所周知的原因,android源码被墙了,还好国内有不少镜像,这里使用清华提供的镜像. 以下内容转自: https://wiki.tuna.tsinghua.edu.cn/MirrorUsage/an ...

  8. 安装ubuntu16虚拟机,下载android源码,配置编译环境

    Android 源码编译步骤: 我考虑了一下,目前电脑装了SSD,8G内存,使用虚拟机编译源码应该够用. 首先下载虚拟机软件,由于最近一直在使用virtualbox,感觉蛮不错了,下载地址: http ...

  9. 转:Windows下载Android源码

    原文来自于:http://blog.csdn.net/hlf48641715/article/details/7188450 下载msysgit,安装 官方下载:http://code.google. ...

随机推荐

  1. 20145316许心远《Java程序设计》第4周学习总结

    20145316许心远<Java程序设计>第4周学习总结 教材学习内容总结 6.继承与多态 1.继承共同行为 * 多个类中存在相同属性和行为时,将这些内容抽取到单独一个类中,那么多个类无需 ...

  2. JSON.stringify without quotes on properties?

    https://stackoverflow.com/questions/11233498/json-stringify-without-quotes-on-properties/11233515 va ...

  3. git删除本地分支和删除远程分支

    引言: 切换分支的时候命令打错了,git checkout 后面没有跟分支名,结果git status,很多delete的文件,直接冒冷汗,git add ,commit 之后发现本地与远程确实是删除 ...

  4. CF1137F Matches Are Not a Child's Play(LCT思维题)

    题目 CF1137F 很有意思的题目 做法 直接考虑带修改的做法,上一次最大值为u,这次修改v,则最大值为v了 我们发现:\(u-v\)这条链会留到最后,序列里的其他元素相对位置不变,这条链会\(u\ ...

  5. 聊一聊HTML <!DOCTYPE> 标签

    一般一个基本html页面的结构,如下代码所示: <html> <head> <title>我是基本的页面结构</title> </head> ...

  6. 【前端】javascript中10常用的个小技巧总结

    javascript中10常用的个小技巧总结 本文转自:http://www.cnblogs.com/libin-1/p/6756393.html 1. new Set() 可能有人知道ES6中提供了 ...

  7. wamp 环境下配置多台虚拟主机

    首先启动wamp,成功之后,单击图标,找到Apache服务器下的 httpd.conf ,直接打开 按下Ctrl+F键,在搜索框中搜索 Virtual hosts, 搜寻结果如下图: 3. 然后打开w ...

  8. windchill系统安装大概步骤

    1.安装VMware Workstation虚拟机 2.win7的64位操作系统(为什么不用32位?因为32位的内存最大只能设置4G) 3.安装Oracle数据库(映射iso文件[上面栏的虚拟机-&g ...

  9. python 类和对象的属性

    python类和对象的属性分为类属性和对象属性两大类,类属性属于类,而对象属性属于对象. 1. 父类的对象属性会被子类的对象继承. 2. 父类的类属性会被子类继承,还是作为类属性,如果父类改变了类属性 ...

  10. GridControl 史上最全的资料(一)

    GridControl详解(一)原汁原味的表格展示 Dev控件中的表格控件GridControl控件非常强大.不过,一些细枝末节的地方有时候用起来不好找挺讨厌的.使用过程中,多半借助Demo和英文帮助 ...