0 前言
本文介绍如何下载MediaTek平台的Android源码,然后进行编译。
相关:《Android源码下载与编译(TI)》
安装工具1个
下载Android源码需要git、repo等工具。 Starting repo是Google专门编写的一个用于下载Android源码的工具,主要调用git。
(1)安装git
sudo apt-get install git
(2) 安装仓库
repo是Google编写的Python脚本,用于管理多个git仓库android 源码编译 adb,专用于Android源码下载。
下载存储库,更改可执行权限,然后连接到 /usr/bin 目录:
chomd +x repo
sudo mv repo /usr/bin
2 下载安卓
由于谷歌被屏蔽,直接从谷歌官网下载Android源代码是很困难的,所以需要另辟蹊径。 高通开源网络是一个不错的选择。 本文下载支持MediaTek msm8909平台的Android源码。 安卓版本是6.0.1。 详细步骤如下:
mkdir android-msm8909
cd android-msn8909
repo init -u git://codeaurora.org/platform/manifest.git -b release -m LA.BR.1.2.6.c1-02100-8x09.0.xml
repo sync -j4
笔记:
a) 源代码大小为40GB,下载过程需要几个小时;
b) 在Snapdragon开源网站上查看上述LA.BR.1.2.6.c1-02100-8x09.0.xml:
3 编译Android 3.1 安装JDK
通过《Android源码编译--jdk版本查询》查看上述源码所需的JDK版本,得知需要安装OpenJDK-1.7:
sudo apt-get install openjdk-7-jdk
3.2 编译
1)进入android-msm8909目录:
cd android-msm8909
source build/envsetup.sh
lunch 27
make -j4
# or
make -j4 showcommands dist
笔记:
3.3 编译结果
编译完成后,产生的相关镜像在out/target/product子目录下android 源码编译 adb,例如:
其中,linux内核编译结果保存在obj/KERNEL_OBJ目录下(Linux内核也是一起编译的,不需要单独编译!)。
4 编译sdk
详情请参见《Android源码编译SDK》。
5 编译内核
make bootimage
6 编译其他模块
参考文献[37]总结了各个模块的编译方式:
make sdk - build the tools that are part of an SDK (adb, fastboot, etc.)
make snod - build the system image from the current software binaries
make services
make runtime
make droid - make droid is the normal build.
make all - make everything, whether it is included in the product definition or not
make clean - remove all built files (prepare for a new build). Same as rm -rf out//
make modules - shows a list of submodules that can be built (List of all LOCAL_MODULE definitions)
make - make a specific module (note that this is not the same as directory name. It is the LOCAL_MODULE definition in the Android.mk file)
make clean- - clean a specific module
make bootimage TARGET_PREBUILT_KERNEL=/path/to/bzImage - create a new boot image with custom bzImage
参考
[1] Ubuntu下载并编译Android5.1源码
[2] 国内镜像加速Android源码下载
[3]在Ubuntu系统中下载Android源码(5.1.1_r8)
[4]ubuntu repo计划和代码下载
[5]Android系统源码下载
[6]下载android4.4.2源码全过程(附上下载的源码)
[7]Android 4.4源码下载-百度云盘地址
[8]基于Ubuntu 14.04 LTS编译Android4.4.2源码
[9]高通平台Android开发总结