单机搭建Android开发环境(四)
单机搭建安卓开发环境,前三篇主要是磨刀霍霍,这一篇将重点介绍JDK、REPO、GIT及编译工具的安装,下载项目代码并编译。特别说明,以下操作基于64位12.04 Server版Ubuntu。若采用其他版本系统,请参考Google官方操作步骤。访问不了的同学,请找大师(蓝灯),他能助你一臂之力。
1)安装OpenJDK 7
sudo apt-get install openjdk-7-jdk --force-yes –y
安装OpenJDK8
sudo add-apt-repository ppa:openjdk-r/ppa
sudo apt-get update
sudo apt-get install openjdk-8-jdk --force-yes -y
查看java的版本
java –version
java version "1.7.0_95"
OpenJDK Runtime Environment (IcedTea 2.6.4) (7u95-2.6.4-0ubuntu0.12.04.1)
OpenJDK 64-Bit Server VM (build 24.95-b01, mixed mode)
设置环境变量
vim ~/.profile
在末尾添加如下配置,保存并退出
export JAVA_HOME=/usr/lib/jvm/java-7-openjdk-amd64
export CLASSPATH=.:$JAVA_HOME/lib:$JAVA_HOME/jre/lib:$CLASSPATH
export PATH=$JAVA_HOME/bin:$JAVA_HOME/jre/bin:$PATH
终端输入如下命令使配置生效
source ~/.profile
2)安装google推荐的编译工具
sudo apt-get install gnupg flex bison gperf build-essential --force-yes -y
sudo apt-get install zip curl libc6-dev libncurses5-dev:i386 x11proto-core-dev --force-yes -y
sudo apt-get install libx11-dev:i386 libreadline6-dev:i386 --force-yes -y
sudo apt-get install libgl1-mesa-dev g++-multilib mingw32 tofrodos --force-yes -y
sudo apt-get install python-markdown libxml2-utils xsltproc zlib1g-dev:i386 --force-yes -y
sudo apt-get install libgl1-mesa-dri:i386 dpkg-dev --force-yes –y
3)安装repo
下载repo V1.22国内定制版,已处理原版在国内使用时出现如下错误提示:
fatal: Cannot get https://gerrit.googlesource.com/git-repo/clone.bundle
fatal: error [Errno 101] Network is unreachable
将repo拷贝到/bin目录下,并修改其属性
sudo cp /home/repo /bin/
sudo chmod a+x /bin/repo
4)安装git
sudo apt-get install git --force-yes –y
配置用户邮箱及用户名
git config --global user.email "hjb@mail.com"
git config --global user.name "hjb"
配置完成后可通过git config --list查看配置信息,或通过cat ~/.gitconfig查看git配置文件的详细信息。
5)创建密钥,并添加到服务器端
ssh-keygen -t rsa -C hjb@bonovo.com
拷贝id_rsa.pub并重命名,然后复制到服务器
cp /home/hjb/.ssh/id_rsa.pub /home/hjb/id_rsa.pub.hjb113
在git服务器端登录bnv用户,并执行如下命令,
cat /home/hjbang/id_rsa.pub.hjb113 >> /home/bnv/.ssh/authorized_keys
6)本地创建project目录mt8735,准备下载代码
cd ~
mkdir mt8735
cd mt8735
7)同步代码
repo init -u bnv@192.168.1.12:/home/git/MTK/lp5.1-mt8735m-mirror/bonovo/platform/manifests.git -b default
repo sync
repo forall -c git checkout lp5.1-mt6735m
repo forall -c git checkout mt8735-avn401
repo forall -c git pull
8)安装ccache,并配置ccache
sudo apt-get install -y ccache
配置.bashrc
sudo vim ~/.bashrc
末尾添加
export USE_CCACHE=1
使配置及时生效
source ~/.bashrc
查看设置状态:
echo $USE_CCACHE
9)编译project
cd ~/mt8735
prebuilts/misc/linux-x86/ccache/ccache -M 50G
. build/envsetup.sh
launch 25
make update-api
make update-api,大概需要花18分钟,详细信息如下,
Docs droiddoc: out/target/common/docs/doc-comment-check DroidDoc took sec. to write docs to out/target/common/docs/doc-comment-check Copying current.txt Copying removed.txt Docs droiddoc: out/target/common/docs/system-api-stubs DroidDoc took sec. to write docs to out/target/common/docs/system-api-stubs Copying system-current.txt Copying system-removed.txt #### make completed successfully (: (mm:ss)) ####
编译Android5.1系统
make –j24
编译过程非常漫长,可以通过如下命令查看cahe使用情况,
watch -n1 -d prebuilts/misc/linux-x86/ccache/ccache -s
cache directory /home/hjb/.ccache cache hit (direct) cache hit (preprocessed) cache miss called for link preprocessor error unsupported source language unsupported compiler option files in cache cache size 18.0 Gbytes max cache size 50.0 Gbytes
可以看到cache大概有18GB,故使用ccache,第一次编译的时间会比不用cache更长,但之后编译速度将会有很大提升。
经过4个半小时,第一次编译终于成功了,详细信息如下,
Creating filesystem with parameters: Size: Block size: Blocks per group: Inodes per group: Inode size: Journal blocks: Label: Blocks: Block groups: Reserved block group size: Created filesystem with / inodes and / blocks Install system fs image: out/target/product/mt8735_tb_l1/system.img out/target/product/mt8735_tb_l1/system.img+out/target/product/mt8735_tb_l1/obj/PACKAGING/recovery_patch_intermediates/recovery-from-boot.p maxsize= blocksize= total= reserve= #### make completed successfully (:: (hh:mm:ss)) ####
修改内核模块代码,重新编译系统镜像大概需要13分钟,详细信息如下,
Creating filesystem with parameters: Size: Block size: Blocks per group: Inodes per group: Inode size: Journal blocks: Label: Blocks: Block groups: Reserved block group size: Created filesystem with / inodes and / blocks Install system fs image: out/target/product/mt8735_tb_l1/system.img out/target/product/mt8735_tb_l1/system.img+out/target/product/mt8735_tb_l1/obj/PACKAGING/recovery_patch_intermediates/recovery-from-boot.p maxsize= blocksize= total= reserve= #### make completed successfully (: (mm:ss)) ####
虽然在SSD上编译,这个时间会缩短到5分钟左右,但还是比较长。所以在调试内核驱动模块时,最好使用动态加载模块的方式,以提高工作效率。
至此,Android系统编译的环境基本搭建完成,后一篇将介绍如何搭建Android应用开发的环境。
单机搭建Android开发环境(四)的更多相关文章
- 单机搭建Android开发环境(三)
单机搭建Android开发环境,第一篇重点介绍了如何优化Windows 7系统,以提高开发主机的性能并延长SSD的使用寿命.第二篇重点介绍了基于VMWare安装64位版的Ubuntu 12.04,并安 ...
- 单机搭建Android开发环境(二)
前文介绍了如何优化SSD和内存,以发挥开发主机的最佳性能,同时提到在SSD上创建虚拟机.为什么不装双系统呢?双系统性能应该会更好!采用Windows+虚拟机的方式,主要是考虑到安卓开发和日常办公两方面 ...
- 单机搭建Android开发环境(一)
老话,工欲善其事必先利其器.为了学习安卓系统开发,我下了血本,更换了电脑.俗语,磨刀不误砍柴工,好钢用在刀刃上,为了发挥新本的最大潜能,我花费了很长时间去做配置和优化,都感觉有点偏执了.不过,从到目前 ...
- 单机搭建Android开发环境(五)
前文介绍了Android系统开发环境的搭建,本文将简单介绍Android应用开发环境的搭建. 基于Android Studio搭建应用开发环境,相比使用Eclipse简单得多.Android Stud ...
- 在Eclipse下搭建Android开发环境教程
我们昨天向各位介绍了<在NetBeans上搭建Android SDK环境>,前不久也介绍过<在MyEclipse 8.6上搭建Android开发环境>, 都受到了读者的欢迎.但 ...
- 第二章 搭建Android开发环境--读书笔记
俗话说,工欲善其事,必先利其器,对于Android驱动开发来说,首先我们要做的就是搭建Android开发环境,我们首先要配置Linux驱动的开发环境,接着还得配置开发Android应用程序以及Andr ...
- Windows上搭建android开发环境
在搭建android开发环境时需要四部分内容,框架如下 其中Java SDK和Eclipse在java4android中有过介绍,重点介绍ADT和Android SDK的安装. 安装Android S ...
- Ubuntu 12.04 搭建Android开发环境
Ubuntu 12.04 搭建Android开发环境 2013/7/29 Linux环境下搭建Android开发环境 大部分开发人员可能都在Windows下做开发,可能是感觉在Windows下比较方便 ...
- 如何在Windows上搭建Android开发环境
Android开发越来越火,许多小伙伴们纷纷学习Android开发,学习Android开发首要任务是搭建Android开发环境,由于大家 主要实在Windows 上开发Android,下面就详细给大家 ...
随机推荐
- JAVASCRIPT中经典面试题
//1.try catch finally中的return var n=1; function fun(){ try{ n++; m++;//报错 return n; }catch(err){ n++ ...
- 当jquery ajax遇上401请求
jquery ajax是个很常用接口,而在请求时候,可能存在响应401的情况(身份认证过期或未登录),比较容易出现在混合应用上,如何进行身份认证,重发失败请求,还是值得注意的. ajax请求有两种方式 ...
- 如何将List<string>转化为string
Convert List, string. A List can be converted to a string. This is possible with the ToArray method ...
- JavaScript中的各种变量提升(Hoisting)
首先纠正下,文章标题里的 “变量提升” 名词是随大流叫法,“变量提升” 改为 “标识符提升” 更准确.因为变量一般指使用 var 声明的标识符,JS 里使用 function 声明的标识符也存在提升( ...
- 27款后台管理页面设计 DIV+CSS+JS
-----------. 演示: http://www.websjy.com/club/websj ... _61040268/index.htm http://www.websjy.com/club ...
- C#的3DES加密解密算法
C#类如下: using System; using System.Collections.Generic; using System.Text; using System.Security.Cryp ...
- ubuntu处理中文时设置locale
ubuntu下涉及中文处理的程序时,需要正确设置,否则会出现问号或者乱码的情况 具体的原因: http://wiki.ubuntu.org.cn/Locale locale的解释 http://wik ...
- 超人学院二期学员分享hadoop工作经验
定于2月17日--2月23日的某一天,邀请咱们学员分享一下hadoop工作经验.对于没工作过的同学或者没从事过hadoop工作的同学,抓住机会啊,你可以提前准备自己关心的各种问题! 具体时间请关注QQ ...
- Android Action Bar简介
Android Action Bar简介 Design: Action Bar Action Bar是在屏幕顶端的一部分内容,通常在整个app进行中都保持存在. 它提供了几个关键的功能: 1.使得重要 ...
- CAGradientLayer的一些属性解析
CAGradientLayer的一些属性解析 iOS中Layer的坐标系统: 效果: - (void)viewDidLoad { [super viewDidLoad]; CAGradientLaye ...