您的位置:首页 > 移动开发 > Android开发

Ubuntu14.04下载&编译Android(1)

2016-08-03 18:10 477 查看
1 安装git&repo&curl

    下载Android源码需要git,repo等工具,启动repo是Google写的一个专门用于下载Android源码的工具,主要调用了git。

(1)安装git

sudo apt-get install git
(2)安装repo

    下载repo,改变可执行权限,然后移动到/usr/bin目录中即可:

chomd +x repo
sudo mv repo /usr/bin


2 下载Android

    由于Google被墙了,因此无法直接从Google官网下载Android源码,因此需要另觅途径,高通开源网是一个不错的选择。本文在其中下载支持高通msm8909平台的Android源码,Android版本为6.0.1,详细步骤如下:

1)创建源码目录

mkdir android-msm8909
2)进入源码目录,然后初始化repo

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
3)同步源码(下载)

repo sync -j4
    注意:

    a)源码大小有40GB,下载过程要几个小时;

    b)上述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


2)配置环境变量:

source build/envsetup.sh


3)执行下面命令选择产品:

lunch



    

在上图中选择一个版本(我选择了27),然后按回车键即可。

4)执行下面命令启动编译:

make




make -j4 showcommands dist


参数说明:

    -j4, 开启4个线程;

    showcommands, 显示编译过程中执行的命令[38];

    dist, 将编译后产生的发布文件拷贝到out/dist目录中[38];

3.3 编译结果

    编译完成后,生产的相关镜像在out/target/product的子目录中,例如:



    其中,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/<configuration>/
make modules - shows a list of submodules that can be built (List of all LOCAL_MODULE definitions)
make <local_module> - 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-<local_module> - 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]Qualcomm平台android开发总结

[10]高通android平台源码 (2011-03-28 10:56)

[11]在官网途径无法下载到android 源码时,,你可通过这种方式去下载

[12]高通平台android开发总结(7630)

[13]Android for MSM Project

[14]Qualcomm平台android开发总结

[15]高通平台android开发总结 MSM平台上的AMSS

[16] android源码下载(上)

[17]android源码下载(下)

[18]开源代码下载路径

[19]如何下载并编译Android4.0内核源码goldfish(图文)

[20]Android源码、内核编译

[21]如何下载Android kernel内核源代码,编译烧写验证

[22]编译Android系统源码和内核源码

[23]Android源码编译的全过程记录

[24]在Ubuntu 14.04系统中编译Android 5.1.1源码

[25]Android AOSP 5.1.0 & 5.0.1源代码百度云下载

[26]Android 6.0 源代码编译实践

[27]自己动手编译Android源码(超详细)

[28]Android学习系列(38)--Android源码下载和编译

[29]Android SDK 源代码编译

[30]编译时候 make和 make sdk有什么区别?

[31]android 如何制作自己的sdk

[32]Android 源码编译 make sdk ADT

[33]android编译SDK问题汇总

[34]如何在linux下编译windows版android sdk

[35]ubuntu12.04(64bit)编译android4.2.2源代码及SDK步骤

[36]Android_SDK编译,带自己api的android.jar编译

[37]Android Build System

[38]Android源代码编译命令m/mm/mmm/make分析
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: