10.04下编译Android源码:
在用高版本的Ubuntu来编译Android源码的时候碰到的最多的就是要安装旧版本的gcc,g++和JDK。而这些在新版本的新立得里面 是没有提供安装的。这里只要修改简单的配置即可利用新立得来安装。
1、 备份/etc/apt/sources.list
运行:sudo mv /etc/apt/sources.list /etc/apt/sources.list.bak
2、 编辑新的source.list
运行:sudo gedit /etc/apt/sources.list
增加
deb http://cz.archive.ubuntu.com/ubuntu dapper main multiverse
deb http://cz.archive.ubuntu.com/ubuntu lucid main universe
3、 运行sudo apt-get update
然后在新立得里面输入gcc-4.3 , g++-4.3,和 sun-java5-就可以看到自己需要的版本了。在下载完成之后,删除高版本的gcc和g++,重新建立链接就可以了。
4、 sudo rm /usr/bin/gcc
sudo rm /usr/bin/g++
5、 sudo ln -s /usr/bin/gcc-4.3 /usr/bin/gcc
sudo ln -s /usr/bin/g++-4.3 /usr/bin/g++
关于JDK版本的切换参考:
参考:http://blog.youkuaiyun.com/skywalkzf/archive/2010/02/08/5297898.aspx
然后就可以使用高版本了。
目前源码仅提供MacOS,和Linux上的编译。这里主要以ubuntu为例,首先准备系统环境Git/JDK,软件包列表flex, bison, gperf, libsdl-dev, libesd0-dev, libwxgtk2.6-dev (optional), build-essential, zip, curl
sudo apt-get install git-core gnupg
sudo apt-get install sun-java6-jdk
sudo apt-get install flex bison gperf libsdl-dev libesd0-dev libwxgtk2.6-dev build-essential zip curl libncurses5-dev zlib1g-dev
sudo apt-get install valgrind
其中的版本要求Python2.4/JDK 5.0, update 12或更高/Git 1.5.4
安装Repo
Make sure you have a ~/bin directory in your home directory, and check to be sure that this bin directory is in your path:
cd ~
mkdir bin
echo $PATH
Download the repo script and make sure it is executable:
curl http://android.git.kernel.org/repo >~/bin/repo
chmod a+x ~/bin/repo
Create an empty directory to hold your working files:
mkdir mydroid
cd mydroid
Run repo init to bring down the latest version of Repo with all its most recent bug fixes. You must specify a URL for the manifest:
repo init -u git://android.git.kernel.org/platform/manifest.git
When prompted, configure Repo with your real name and email address. If you plan to submit code, use an email address that is associated with a Google account.
获取源码
repo sync
修改环境变量
vi /etc/profile
export ANDROID_JAVA_HOME=$JAVA_HOME
开始编译
cd ~/mydroid
make