android 源码的下载和编译
2016-03-20 08:30
387 查看
最近因为工作需要,需要下载一份android 源码在自己的ubuntu 笔记本上使用。于是就想下载一份android6.0.1的代码,编译一下,已做浏览代码和调试用。
由于android 的网站在国内被墙,只能从国内镜像网站下载源码,我选择了清华的镜像网站:
安装git:
sudo apt-get install git
下载repo 工具
创建目录:
初始化仓库:
查看自己的cpu 内核数,以提高repo sync 和下面编译的速度:
sync 代码:
-c 只会sync 当前使用的分支代码;
编译:
根据使用的ubuntu 的版本不一样,我使用的ubuntu15.10,需要安装一下jdk8,0,bison:
如果机器不是特别强壮,机器内存不大,编译会出现很多错误,比如jack 出错的。由于google 在M中使用了ninja 编译,据说可以提高一些编译速度。
如果是内存溢出,可以考虑在/prebuilds/sdk/tools/linux-x86/jack-admin 在start-server的启动中,添加一个-Xmx2560m 启动参数。make -j1 编译。
由于android 的网站在国内被墙,只能从国内镜像网站下载源码,我选择了清华的镜像网站:
安装git:
sudo apt-get install git
下载repo 工具
mkdir ~/bin PATH=~/bin:$PATH curl https://storage.googleapis.com/git-repo-downloads/repo > ~/bin/repo chmod a+x ~/bin/repo
创建目录:
mkdir WORKING_DIRECTORY cd WORKING_DIRECTORY
配置git
git config -global user.name "your name" git config -global user.email "yuremail“
初始化仓库:
repo init -u https://aosp.tuna.tsinghua.edu.cn/platform/manifest # 或 repo init -u git://aosp.tuna.tsinghua.edu.cn/aosp/platform/manifest ## 如果提示无法连接到 gerrit.googlesource.com,可以编辑 ~/bin/repo,把 REPO_URL 一行替换成下面的: REPO_URL = 'https://gerrit-google.tuna.tsinghua.edu.cn/git-repo'
查看自己的cpu 内核数,以提高repo sync 和下面编译的速度:
cat /proc/cpuinfo一般是最大的cpu 内核乘以2;
sync 代码:
repo sync -c -j8
-c 只会sync 当前使用的分支代码;
编译:
根据使用的ubuntu 的版本不一样,我使用的ubuntu15.10,需要安装一下jdk8,0,bison:
//在android 根目录下: source build/envsetup.sh lunch 11
make -j4就可以等待大概两三各小时,就会编译成功
如果机器不是特别强壮,机器内存不大,编译会出现很多错误,比如jack 出错的。由于google 在M中使用了ninja 编译,据说可以提高一些编译速度。
如果是内存溢出,可以考虑在/prebuilds/sdk/tools/linux-x86/jack-admin 在start-server的启动中,添加一个-Xmx2560m 启动参数。make -j1 编译。
相关文章推荐
- 使用C++实现JNI接口需要注意的事项
- Android IPC进程间通讯机制
- Android Manifest 用法
- [转载]Activity中ConfigChanges属性的用法
- Android之获取手机上的图片和视频缩略图thumbnails
- Android之使用Http协议实现文件上传功能
- Android学习笔记(二九):嵌入浏览器
- android string.xml文件中的整型和string型代替
- i-jetty环境搭配与编译
- android之定时器AlarmManager
- android wifi 无线调试
- Android Native 绘图方法
- Android java 与 javascript互访(相互调用)的方法例子
- android 代码实现控件之间的间距
- android FragmentPagerAdapter的“标准”配置
- Android"解决"onTouch和onClick的冲突问题
- android:installLocation简析
- android searchView的关闭事件
- SourceProvider.getJniDirectories