我是新安装的ubuntu kylin14.04 64bit,没有进行特别设置,直接进行下面操作:
一同步代码
1.如果没有安装curl,就先安装它
sudo apt-get install curl
2.到用户目录新建bin目录
mkdir ~/bin
3.安装git-core
curl https://dl-ssl.google.com/dl/googlesource/git-repo/repo > ~/bin/repo
chmod a+x ~/bin/repo 设置可执行权限
4.添加环境变量
PATH=~/bin:$PATH
5.如果没有安装git,安装它,否则会提示类似这样的错误:
OSError: [Errno 2] No such file or directoryroot@shanmin-ubuntu:/home/android/src# ../repo init -u git://android.git.kernel.org/platform/manifest.git Traceback (most recent call last): File "../repo", line 595, in <module> main(sys.argv[1:]) File "../repo", line 562, in main _Init(args) File "../repo", line 181, in _Init _CheckGitVersion() File "../repo", line 210, in _CheckGitVersion proc = subprocess.Popen(cmd, stdout=subprocess.PIPE) File "/usr/lib/python2.6/subprocess.py", line 623, in __init__ errread, errwrite) File "/usr/lib/python2.6/subprocess.py", line 1141, in _execute_child raise child_exception OSError: [Errno 2] No such file or directory
apt-get install git
6.下载设置
建一个下载目录mkdir /opt/android4.3
~/bin/repo init -u https://android.googlesource.com/platform/manifest -b android-4.3_r2.1
我在执行这命令的时候,提示:
~/bin/repo: line 1: syntax error near unexpected token `newline' ~/bin/repo: line 1: `<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
这是因为repo下载错误,需要重新安装repo。
下载时如果提示:
Traceback (most recent call last): File "/home/calvin/Android/Android2.0/source/.repo/repo/main.py", line 235, in <module> _Main(sys.argv[1:]) File "/home/calvin/Android/Android2.0/source/.repo/repo/main.py", line 217, in _Main repo._Run(argv) File "/home/calvin/Android/Android2.0/source/.repo/repo/main.py", line 123, in _Run cmd.Execute(copts, cargs) File "/home/calvin/Android/Android2.0/source/.repo/repo/subcmds/init.py", line 223, in Execute self._ConfigureUser() File "/home/calvin/Android/Android2.0/source/.repo/repo/subcmds/init.py", line 165, in _ConfigureUser name = self._Prompt('Your Name', mp.UserName) File "/home/calvin/Android/Android2.0/source/.repo/repo/project.py", line 306, in UserName self._LoadUserIdentity() File "/home/calvin/Android/Android2.0/source/.repo/repo/project.py", line 319, in _LoadUserIdentity u = self.bare_git.var('GIT_COMMITTER_IDENT') File "/home/calvin/Android/Android2.0/source/.repo/repo/project.py", line 1324, in runner p.stderr)) error.GitError: manifests var: *** Please tell me who you are. Run git config --global user.email "you@example.com" git config --global user.name "Your Name" to set your account's default identity. Omit --global to set the identity only in this repository. fatal: empty ident <calvin@lihao-desktop.(none)> not allowed
这时要输入:
git config --global user.email "2581529@qq.com"
git config --global user.name "xundh"
再次执行初始化语句,我的系统上又提示:
A new repo command ( 1.18)is available. You should upgrade soon: cp /opt/android4.3/.repo/repo/repo /home/xundh/bin/repo按提示输入命令:
cp /opt/android4.3/.repo/repo/repo /home/xundh/bin/repo7.同步代码
sudo ~/bin/repo sync
经过漫长的等待(公司网慢,我的电脑同步了3天),看到Syncing work tree : 100%(362/362),done.终于同步好了。
当中也断了几次,断了就重新执行同步代码。下载的文件有7.2G。
进入/opt/android4.3目录,执行make命令,系统提示:
build/core/config.mk:345: *** Error: could not find jdk tools.jar , please install JDK6, which you can download from java.sun.com. Stop.
需要先安装JDK6(网上讲ubuntu本身带了jdk,但不适合编译android,因为oracle禁止第三方分发它的jdk,Linux发行版通常带的是openJDK。不得不说Oracle好牛,更牛的是,到oracle网站想找到jdk6的下载链接,是一件非常困难的事情。)
安装JDK的步骤
安装完JDK6,再执行make,提示/bin/bash: jar: command not found. 执行下面命令:
cd /usr/bin sudo ln -s -f /home/xundh/Downloads/jdk1.6.0_45/bin/jar sudo ln -s -f /home/xundh/Downloads/jdk1.6.0_45/bin/java sudo ln -s -f /home/xundh/Downloads/jdk1.6.0_45/bin/javac sudo ln -s -f /home/xundh/Downloads/jdk1.6.0_45/bin/javah sudo ln -s -f /home/xundh/Downloads/jdk1.6.0_45/bin/javadoc
回到android4.3目录,再次运行make
提示:
prebuilts/tools/gcc-sdk/gcc: line 40: prebuilts/tools/gcc-sdk/../../gcc/linux-x86/host/i686-linux-glibc2.7-4.6/bin/i686-linux-gcc:No such file or directory
安装依赖的工具,执行命令:
sudo apt-get install flex bison gperf build-essential zip curl sudo apt-get install zliblg-dev libc6-dev lib32ncurses5-dev sudo apt-get install lib32z1 lib32ncurses5 lib32bz2-1.0 sudo apt-get install x11proto-core-dev libx11-dev sudo apt-get install lib32readline-gplv2-dev sudo apt-get install lib32z1-dev libgl1-mesa-dev g++-multilib mingw32 tofrodos python-markdown libxml2-utils xsltproc
这些依赖包有些可以合并执行,但有些搞不清版本,我就麻烦一点挨个安装了。
再执行make,开始编译。几小时后,报下面错误:
android 编译 can't locate switch.pm in @INC you may need to install the switch module
执行命令,安装switch module:
sudo apt-get install libswitch-perl
三 运行:
source build/envsetup.sh
lunch full-eng
emulator 命令启动虚拟机。