一、ubuntu 12.04 64位 android 编译环境安装
2018-01-31 19:56
706 查看
在闲鱼花300多买了个Nexus 5 手机准备学习android4.4.4源码。Nexus 5 刷入从第三方下载的ROM后,总是推送各种第三方APP,于是自己打算下载编译一次官方的源码。
硬件环境:
64 位系统环境编译(2.3及2.3系统上都是64位环境)
至少100GB的磁盘空间用于校验。单个版本编译需要150GB磁盘空间,多版本编译需要200GB以上成磁盘空间
如果在虚拟机上运行 Lunix,至少需要 16GB的RAM/swap空间。
注:上述环境是官方以最新版本为要求的环境。我打算用VM 虚拟机运行Lunix编译,目前的方案是 动态分配硬盘大小为150G,内存分配 4GB,交换空间分配8GB。
软件环境
1.操作系统
Linux:
Android 2.3.x (Gingerbread) - Android 5.x (Lollipop): Ubuntu 12.04 (Precise)
2. Java Development Kit (JDK)
Android 2.3.x (Gingerbread) - Android 4.4.x (KitKat): Ubuntu - Java JDK 6, Mac OS - Java JDK 6
3. Key packages
Python 2.6 – 2.7 下载官网 python.org
GNU Make 3.81 – 3.82 下载官网:gnu.org ; Android 4.0.x (Ice Cream Sandwich) 以及之前的版本需要 使用 maker 3.81 来避免编译错误。
Git 1.7 + 下载官网 git-scm.com
操作系统:ubuntu-12.04.5-desktop-amd64.iso VMare下载:https://www.cr173.com/soft/177242.htmlubuntu下载:进入ubuntu官网:http://releases.ubuntu.com/后,找到Ubuntu 12.04.5 LTS (Precise Pangolin)或者已经归档的12.04文件夹
![](https://oscdn.geek-share.com/Uploads/Images/Content/201911/10/6cdc5d61f802a2ccc3f64c050c65caed)
安装成功后安装VM Tools,这里不介绍
下载:http://www.oracle.com/technetwork/java/javase/downloads/java-archive-downloads-javase6-419409.html
详细安装及环境变量配置参考我这篇博文: Ubuntu 下JDK的安装与环境配置
![](https://oscdn.geek-share.com/Uploads/Images/Content/201911/10/93a1fe0917659db89be54d18dc38dd96)
参考文章:
Perform an update or upgrade to Precise from a previous release. Only those installing from the 12.04.2 or newer point release media will automatically receive a newer enablement stack by default.
Perform a network install using the netboot images rather than the new <release>-netboot images, eg. quantal-netboot images.
Anyone wishing to opt into the hardware enablement stack for Precise may do so by installing the linux-generic-lts-<release> and xserver-xorg-lts-<release> packages. For example to install the Quantal hardware enablement packages in Precise, please run the following command:将libgl1-mesa-glx:i386替换为libgl1-mesa-glx-lts-<release>:i386
例如:我的ubuntu版本为12.04.5就使用如下命令:sudo apt-get install git gnupg flex bison gperf build-essential zip curl libc6-dev libncurses5-dev:i386 x11proto-core-dev libx11-dev:i386 libreadline6-dev:i386 libgl1-mesa-glx-lts-trusty:i386 libgl1-mesa-dev g++-multilib mingw32 tofrodos python-markdown libxml2-utils xsltproc zlib1g-dev:i386
![](https://oscdn.geek-share.com/Uploads/Images/Content/201911/10/5c85629fc80432a37167b9891298986b)
![](https://oscdn.geek-share.com/Uploads/Images/Content/201911/10/ec9f5779afdac2c6875de3db2d5f209f)
安装成功!4.配置 USB 使用权限如果在乌班图系统下编译后,并用USB数据线进行对NEXUS 5 刷机,那么默认情况下普通用户无法直接使用 USB 设备。需要以root用户身份在‘/etc/udev/rules.d/51-android.rules’下创建一个文件。
为此,请运行以下命令来下载本网站附带的 51-android.txt 文件,对其进行修改以包含您的用户名,然后将其放到正确位置
![](https://oscdn.geek-share.com/Uploads/Images/Content/201911/10/4b54f670d0d2cfff7b742a3ea08f1de4)
![](https://oscdn.geek-share.com/Uploads/Images/Content/201911/10/1ca98ee14f4688af66171ea3109d9565)
要进行这项设置,请导出 OUT_DIR_COMMON_BASE 变量,使其指向将存储输出目录的位置。
例如,如果您有源代码树 /source/master1 和 /source/master2,并且 OUT_DIR_COMMON_BASE 设为了 /output,那么输出目录将为 /output/master1 和 /output/master2。这个过程后续会验证
按照如下步骤进行安装Repo.
![](https://oscdn.geek-share.com/Uploads/Images/Content/201911/10/b7990d2a61d7870c946222fe5dfca0f5)
即:2.进入Android444_r1 目录,运行 repo init 来下载相应版本
![](https://oscdn.geek-share.com/Uploads/Images/Content/201911/10/f2b009b724fdee43c1616590bb84123e)
下载成功后提示:
![](https://oscdn.geek-share.com/Uploads/Images/Content/201911/10/b44c770ee6c558a9eedead817aa2f900)
checkout出的代码有9.4G
![](https://oscdn.geek-share.com/Uploads/Images/Content/201911/10/8f96acd3010e8849e7e1b5fd412eaf38)
进入隐藏的 .repo目录,查看当前分支大小,有64G呢
![](https://oscdn.geek-share.com/Uploads/Images/Content/201911/10/24b25aad27526a9b15630382af2ab7c5)
如果想check out 其它分支代码,将工作目录下check out出的代码删除,保留隐藏的.repo 目录,重新初始化分支执行上述流程就行,这时会快很多。
总结起来就是太耗时间。进入考试月了,等考完试,计划再实战出 android 4.4.4.r1 系统编译篇、内核编译篇、内核反调试修改编译篇、以及ROM镜像和内核的刷机教程。小白的学习记录过程分享,大神不要喷呀。
转自:http://blog.csdn.net/u012417380/article/details/72809141
一、编译环境搭建
1.官方推荐环境介绍
关于Android各个版本的编译环境的搭建,大家可以参考我去年翻译的Android 官方文档http://blog.csdn.net/u012417380/article/details/51472860。我目前打算用VM虚拟机编译Android 4.4.4 版本,它官方要求的具体环境是:硬件环境:
64 位系统环境编译(2.3及2.3系统上都是64位环境)
至少100GB的磁盘空间用于校验。单个版本编译需要150GB磁盘空间,多版本编译需要200GB以上成磁盘空间
如果在虚拟机上运行 Lunix,至少需要 16GB的RAM/swap空间。
注:上述环境是官方以最新版本为要求的环境。我打算用VM 虚拟机运行Lunix编译,目前的方案是 动态分配硬盘大小为150G,内存分配 4GB,交换空间分配8GB。
软件环境
1.操作系统
Linux:
Android 2.3.x (Gingerbread) - Android 5.x (Lollipop): Ubuntu 12.04 (Precise)
2. Java Development Kit (JDK)
Android 2.3.x (Gingerbread) - Android 4.4.x (KitKat): Ubuntu - Java JDK 6, Mac OS - Java JDK 6
3. Key packages
Python 2.6 – 2.7 下载官网 python.org
GNU Make 3.81 – 3.82 下载官网:gnu.org ; Android 4.0.x (Ice Cream Sandwich) 以及之前的版本需要 使用 maker 3.81 来避免编译错误。
Git 1.7 + 下载官网 git-scm.com
2.本地编译环境搭建
1.用VMare 12.0 创建Linux虚拟机。
虚拟机:动态分配硬盘大小为150G,内存分配 4GB,交换空间分配8GB。操作系统:ubuntu-12.04.5-desktop-amd64.iso VMare下载:https://www.cr173.com/soft/177242.htmlubuntu下载:进入ubuntu官网:http://releases.ubuntu.com/后,找到Ubuntu 12.04.5 LTS (Precise Pangolin)或者已经归档的12.04文件夹
安装成功后安装VM Tools,这里不介绍
2.安装java JDK 1.6
jdk版本:jdk-6u45-linux-x64.bin下载:http://www.oracle.com/technetwork/java/javase/downloads/java-archive-downloads-javase6-419409.html
详细安装及环境变量配置参考我这篇博文: Ubuntu 下JDK的安装与环境配置
3.安装依赖的其它包
用Ubuntu12.04来编译安卓更旧的版本时,安装下面的安装包:$ sudo apt-get install git gnupg flex bison gperf build-essential \ zip curl libc6-dev libncurses5-dev:i386 x11proto-core-dev \ libx11-dev:i386 libreadline6-dev:i386 libgl1-mesa-glx:i386 \ libgl1-mesa-dev g++-multilib mingw32 tofrodos \ python-markdown libxml2-utils xsltproc zlib1g-dev:i386 $ sudo ln -s /usr/lib/i386-linux-gnu/mesa/libGL.so.1 /usr/lib/i386-linux-gnu/libGL.so
出现如下问题:
参考文章:
Kernel LTSEnablementStack - Ubuntu Wiki.htmlhttps://wiki.ubuntu.com/Kernel/LTSEnablementStack
LTS Enablement Stacks
In an effort to support a wider variety of hardware on an existing LTS release, the 12.04.2 and newer point releases will ship with an updated kernel and X stack by default. These newer hardware enablement stacks will be comprised of the newer kernel and X stacks from 12.10 (Quantal), 13.04 (Raring), 13.10 (Saucy), and 14.04 (Trusty). These enablement stacks are only intended for use on x86 hardware at this time. Those running virtual or cloud images should not need these newer enablement stacks and are thus recommended to remain on the original Precise stack. To remain on the original Precise stack there are a few options: Install from a previous 12.04.0 or 12.04.1 point release and update. The previous 12.04.0 and 12.04.1 releases are archived at http://old-releases.ubuntu.com/Perform an update or upgrade to Precise from a previous release. Only those installing from the 12.04.2 or newer point release media will automatically receive a newer enablement stack by default.
Perform a network install using the netboot images rather than the new <release>-netboot images, eg. quantal-netboot images.
Anyone wishing to opt into the hardware enablement stack for Precise may do so by installing the linux-generic-lts-<release> and xserver-xorg-lts-<release> packages. For example to install the Quantal hardware enablement packages in Precise, please run the following command:将libgl1-mesa-glx:i386替换为libgl1-mesa-glx-lts-<release>:i386
例如:我的ubuntu版本为12.04.5就使用如下命令:sudo apt-get install git gnupg flex bison gperf build-essential zip curl libc6-dev libncurses5-dev:i386 x11proto-core-dev libx11-dev:i386 libreadline6-dev:i386 libgl1-mesa-glx-lts-trusty:i386 libgl1-mesa-dev g++-multilib mingw32 tofrodos python-markdown libxml2-utils xsltproc zlib1g-dev:i386
安装成功!4.配置 USB 使用权限如果在乌班图系统下编译后,并用USB数据线进行对NEXUS 5 刷机,那么默认情况下普通用户无法直接使用 USB 设备。需要以root用户身份在‘/etc/udev/rules.d/51-android.rules’下创建一个文件。
为此,请运行以下命令来下载本网站附带的 51-android.txt 文件,对其进行修改以包含您的用户名,然后将其放到正确位置
//51-android.txt # adb protocol on passion (Nexus One) SUBSYSTEM=="usb", ATTR{idVendor}=="18d1", ATTR{idProduct}=="4e12", MODE="0600", OWNER="<username>" # fastboot protocol on passion (Nexus One) SUBSYSTEM=="usb", ATTR{idVendor}=="0bb4", ATTR{idProduct}=="0fff", MODE="0600", OWNER="<username>" # adb protocol on crespo/crespo4g (Nexus S) SUBSYSTEM=="usb", ATTR{idVendor}=="18d1", ATTR{idProduct}=="4e22", MODE="0600", OWNER="<username>" # fastboot protocol on crespo/crespo4g (Nexus S) SUBSYSTEM=="usb", ATTR{idVendor}=="18d1", ATTR{idProduct}=="4e20", MODE="0600", OWNER="<username>" # adb protocol on stingray/wingray (Xoom) SUBSYSTEM=="usb", ATTR{idVendor}=="22b8", ATTR{idProduct}=="70a9", MODE="0600", OWNER="<username>" # fastboot protocol on stingray/wingray (Xoom) SUBSYSTEM=="usb", ATTR{idVendor}=="18d1", ATTR{idProduct}=="708c", MODE="0600", OWNER="<username>" # adb protocol on maguro/toro (Galaxy Nexus) SUBSYSTEM=="usb", ATTR{idVendor}=="04e8", ATTR{idProduct}=="6860", MODE="0600", OWNER="<username>" # fastboot protocol on maguro/toro (Galaxy Nexus) SUBSYSTEM=="usb", ATTR{idVendor}=="18d1", ATTR{idProduct}=="4e30", MODE="0600", OWNER="<username>" # adb protocol on panda (PandaBoard) SUBSYSTEM=="usb", ATTR{idVendor}=="0451", ATTR{idProduct}=="d101", MODE="0600", OWNER="<username>" # adb protocol on panda (PandaBoard ES) SUBSYSTEM=="usb", ATTR{idVendor}=="18d1", ATTR{idProduct}=="d002", MODE="0600", OWNER="<username>" # fastboot protocol on panda (PandaBoard) SUBSYSTEM=="usb", ATTR{idVendor}=="0451", ATTR{idProduct}=="d022", MODE="0600", OWNER="<username>" # usbboot protocol on panda (PandaBoard) SUBSYSTEM=="usb", ATTR{idVendor}=="0451", ATTR{idProduct}=="d00f", MODE="0600", OWNER="<username>" # usbboot protocol on panda (PandaBoard ES) SUBSYSTEM=="usb", ATTR{idVendor}=="0451", ATTR{idProduct}=="d010", MODE="0600", OWNER="<username>" # adb protocol on grouper/tilapia (Nexus 7) SUBSYSTEM=="usb", ATTR{idVendor}=="18d1", ATTR{idProduct}=="4e42", MODE="0600", OWNER="<username>" # fastboot protocol on grouper/tilapia (Nexus 7) SUBSYSTEM=="usb", ATTR{idVendor}=="18d1", ATTR{idProduct}=="4e40", MODE="0600", OWNER="<username>" # adb protocol on manta (Nexus 10) SUBSYSTEM=="usb", ATTR{idVendor}=="18d1", ATTR{idProduct}=="4ee2", MODE="0600", OWNER="<username>" # fastboot protocol on manta (Nexus 10) SUBSYSTEM=="usb", ATTR{idVendor}=="18d1", ATTR{idProduct}=="4ee0", MODE="0600", OWNER="<username>" # adb protocol on hammerhead (Nexus 5) SUBSYSTEM=="usb", ATTR{idVendor}=="18d1", ATTR{idProduct}=="4ee1", MODE="0600", OWNER="<username>"下面的的命令会自动下载
51-android.txt文件,对文件中
<username>字段替换成你的用户名,并将文件放在
/etc/udev/rules.d/51-android.rules文件文件中
$ wget -S -O - http://source.android.com/source/51-android.txt | sed "s/<username>/$USER/" | sudo tee >/dev/null /etc/udev/rules.d/51-android.rules $sudo udevadm control --reload-rules如果显示拒绝连接无法下载的话,将51-android.txt文件放在本地目录任意一目录,在该目录中执行下面的命令。
$ cat 51-android.txt | sed "s/<username>/$USER/" | sudo tee >/dev/null /etc/udev/rules.d/51-android.rules $ sudo udevadm control --reload-rules执行完后,为了验证NEXUS 5 与乌班图是否连接,将nexus 5的USB计算机连接方式设置为相机,可以看到乌班图能够识别设备了。
5.配置单独的输出目录。
默认情况下,每次编译的输出都会存储在相应源代码树的 out/ 子目录下。如果将源文件和输出存储在单独的存储卷中,编译速度会更快。要进行这项设置,请导出 OUT_DIR_COMMON_BASE 变量,使其指向将存储输出目录的位置。
$ export OUT_DIR_COMMON_BASE=<path-to-your-out-directory>对于每个单独的源代码树,其输出目录都将以其存放目录命名。
例如,如果您有源代码树 /source/master1 和 /source/master2,并且 OUT_DIR_COMMON_BASE 设为了 /output,那么输出目录将为 /output/master1 和 /output/master2。这个过程后续会验证
3 下载系统源码
安卓系统源码放在git仓库中1.安装Repo
repo 是安卓环境下的命令行工具,对Git部分命令进行封装,将 百多个git库进行更新。按照如下步骤进行安装Repo.
1.确定你的主目录(home)下有bin目录,并且bin目录变量在你的path环境变量中:
$ mkdir ~/bin $ PATH=~/bin:$PATH
2.下载Repo tool,并且确保它是可执行的。
$ curl https://storage.googleapis.com/git-repo-downloads/repo > ~/bin/repo $ chmod a+x ~/bin/repo
初始化 Repo 客户端
当你安装完Repo后,设置安卓源码仓库的客户端:1.创建一个存放安卓源码的空目录
$ mkdir WORKING_DIRECTORY $ cd WORKING_DIRECTORY由于我下载的版本是 Android4.4.4_r1所以将WORKING_DIRECTORY替换成Android444_r1:
即:
aosp444@aosp444-virtual-machine:~$ mkdir Android444_r1 aosp444@aosp444-virtual-machine:~$ cd Android444_r1 aosp444@aosp444-virtual-machine:~/Android444_r1$
2.进入Android444_r1 目录,运行 repo init 来下载相应版本Android4.4.4_r1
的源码:
$ repo init -u https://android.googlesource.com/platform/manifest -b android-4.4.4_r1由于google站无法访问,所以我选择了清华的下载源,用下面的命令下载
repo init -u https://aosp.tuna.tsinghua.edu.cn/platform/manifest -b android-4.4.4_r1
3.配置你的用户邮箱
repo init 后,会提示你输入名字和邮箱, 两个我都是直接按的回车键,这时它默认将系统用户名和主机名 作为用户名和邮箱,接着我直接按了y,提示repo初始完。$ git config --global user.name "Your Name" $ git config --global user.email "you@example.com"
4.然后同步源码树
$ repo sync接着就是漫长的等待,如果中间出现中断,只要重复该命令即可。
下载成功后提示:
Fetching projects: 100% (413/413), done. Checking out files: 100% (1179/1179), done. Checking out files: 100% (2776/2776), done.ut files: 50% (1390/2776) Checking out files: 100% (44267/44267), done. files: 0% (441/44267) Checking out files: 100% (3628/3628), done.ut files: 35% (1305/3628) Checking out files: 100% (6683/6683), done.out files: 8% (568/6683) Checking out files: 100% (2438/2438), done.out files: 40% (976/2438) Checking out files: 100% (9389/9389), done.out files: 29% (2742/9389) Checking out files: 100% (50822/50822), done.t files: 4% (2060/50822) Checking out files: 100% (140/140), done. Checking out files: 100% (10083/10083), done.t files: 13% (1340/10083) Checking out files: 100% (4307/4307), done.out files: 1% (64/4307) Checking out files: 100% (3494/3494), done.out files: 12% (422/3494) Checking out files: 100% (7954/7954), done. Checking out files: 100% (580/580), done.g out files: 25% (145/580) Checking out files: 100% (1056/1056), done. out files: 48% (510/1056) Checking out files: 100% (11685/11685), done.ut files: 4% (578/11685) Checking out files: 100% (4093/4093), done. out files: 13% (546/4093) Checking out files: 100% (2501/2501), done. out files: 13% (336/2501) Checking out files: 100% (2619/2619), done. out files: 42% (1107/2619) Checking out files: 100% (1654/1654), done. out files: 10% (176/1654) Checking out files: 100% (3924/3924), done. Checking out files: 100% (2570/2570), done. out files: 30% (790/2570) Checking out files: 100% (21973/21973), done. Checking out files: 100% (8597/8597), done. out files: 44% (3802/8597) Checking out files: 100% (1532/1532), done. out files: 40% (620/1532) Checking out files: 100% (1690/1690), done. out files: 32% (557/1690) Checking out files: 100% (376/376), done.ng out files: 9% (37/376) Checking out files: 100% (108/108), done. Checking out files: 100% (171/171), done. Checking out files: 100% (175/175), done.ng out files: 43% (76/175) Checking out files: 100% (181/181), done. Checking out files: 100% (135/135), done. Checking out files: 100% (378/378), done.ng out files: 2% (8/378) Checking out files: 100% (109/109), done. Checking out files: 100% (181/181), done.ng out files: 49% (90/181) Checking out files: 100% (2407/2407), done. Checking out files: 100% (2482/2482), done. Checking out files: 100% (2484/2484), done. out files: 0% (21/2484) Checking out files: 100% (182/182), done. Checking out files: 100% (132/132), done.ng out files: 47% (63/132) Checking out files: 100% (50299/50299), done. Checking out files: 100% (4864/4864), done. Checking out files: 100% (4383/4383), done. Checking out files: 100% (28/28), done.king out files: 46% (13/28) Checking out files: 100% (182/182), done. Checking out files: 100% (1256/1256), done. Checking out files: 100% (2951/2951), done. out files: 20% (606/2951) Syncing work tree: 100% (412/412), done.这时可看到Android444r1文件夹下checkout出的代码:
checkout出的代码有9.4G
进入隐藏的 .repo目录,查看当前分支大小,有64G呢
如果想check out 其它分支代码,将工作目录下check out出的代码删除,保留隐藏的.repo 目录,重新初始化分支执行上述流程就行,这时会快很多。
总结起来就是太耗时间。进入考试月了,等考完试,计划再实战出 android 4.4.4.r1 系统编译篇、内核编译篇、内核反调试修改编译篇、以及ROM镜像和内核的刷机教程。小白的学习记录过程分享,大神不要喷呀。
转自:http://blog.csdn.net/u012417380/article/details/72809141
相关文章推荐
- Android 在Ubuntu 14.04 64位构编译环境的安装流程
- Ubuntu 12.04 64-bit下安装android 2.3.x编译环境指南
- Ubuntu 12.04 64位编译android2.3需要安装的软件
- ubuntu 12.04 下安装android编译环境
- ubuntu 12.04(64位)下搭建Android4.2 编译环境
- Android 源码编译环境搭建(64位Ubuntu)各种依赖包安装
- Ubuntu 12.04 64-bit下安装android 2.3.x编译环境指南2
- Android 编译环境快速安装(基于ubuntu 12.04 64bits)
- ubuntu 12.04(64位 server)下搭建 android2.3/android4.0开发环境及遇到的编译问题
- Ubuntu 12.04 编译Android 4.0.3 的环境配置
- 64位 Ubuntu 12.04 安装Android 报错 (Unable to run 'adb' )
- 64位ubuntu 11.10系统安装android开发环境的过程
- Ubuntu 12.04安装MySQL,JDK 7,Eclipse搭建android开发环境
- ubuntu 12.04(64位)下搭建android2.3/android4.2/4.1/4.0开发环境
- Ubuntu系统 + VMware虚拟机+32位编译环境 安装编译Android2.3源码
- 64位Ubuntu编译android的环境配置问题
- Ubuntu 12.04(64位)下载并编译 Android 4.1 源码
- Ubuntu上搭建android BSP的开发编译环境 && 设置定时编译任务 && ubuntu从10.04升级到12.04后编译出错
- 64位ubuntu 12.04安装android eclipse plugin需要注意的地方
- 64位Ubuntu编译android的环境配置问题