Building Android 4.0 on Ubuntu 11.10

本文提供了一个详细指南,教你如何在Ubuntu 11.10版本上成功安装并编译Android 4.0(代号为“冰激凌三明治”)源代码。包括安装依赖、更新GCC版本、下载并配置Java环境、下载源代码包、初始化构建环境、下载并安装所需软件包等步骤。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

转自:http://mjanja.co.ke/2011/11/building-android-4-0-on-ubuntu-11-10/

Building Android 4.0 on Ubuntu 11.10

By Alan on November 20, 2011
The source code for Android 4.0 “Ice Cream Sandwich” was released last week, and Google’s build instructions list Ubuntu 10.04 as the only officially “supported” configuration for building AOSP on Linux. As of this writing Ubuntu 10.04 is a year and a half old, so lots of people have moved on to newer versions, some of which cause problems due to missing/renamed packages, conflicting versions, etc.


Ubuntu 11.10 in particular is troublesome because it uses gcc-4.6 by default and has nosun-java6-jdk in its repositories. Here’s what you’ll need to do to get AOSP 4.0.x to compile on Ubuntu 11.10.


Install dependencies


Compilers, parsers, file-manipulation tools, libraries, etc; this is mandatory! The list on the source.android.com Inititalizing a Build Environment page is similar, but a few of those packages don’t exist in 11.10. Use these:


sudo apt-get update
sudo apt-get install git-core gnupg flex bison gperf build-essential zip curl zlib1g-dev libc6-dev lib32ncurses5-dev ia32-libs \
x11proto-core-dev libx11-dev lib32z1-dev libgl1-mesa-dev g++-multilib mingw32 tofrodos python-markdown libxml2-utils
Install an “old” GCC


In addition to building applications for the phone, Android’s build system builds a few tools for the host operating system (such as the tools in the SDK). The initial release of the Ice Cream Sandwich source code has a few incompatibilities with the version of the GNU C compiler which comes with Ubuntu 11.10 (GCC 4.6). Install GCC 4.4 from Ubuntu’s repositories:


sudo apt-get install gcc-4.4 g++-4.4 g++-4.4-multilib gcc-4.4-multilib
Small fix for libX11, which some statically-linked programs might need:


sudo ln -s /usr/lib/i386-linux-gnu/libX11.so.6 /usr/lib/i386-linux-gnu/libX11.so
Download Sun Java 6 JDK


Android 2.3+ requires Java 6 to build correctly. While OpenJDK did work for 2.3, it doesn’t work for Android 4.0; you need Sun Java. Download the JDK 1.6 binary release from Sun’s Java download site and unzip it somewhere in your system, for example:


sudo mkdir -p /opt/java/64/
sudo cp jdk-6u29-linux-x64.bin /opt/java/64
sudo su -
cd /opt/java/64
chmod +x jdk-6u29-linux-x64.bin
./jdk-6u29-linux-x64.bin
exit
Add the new Java to your shell environment’s $PATH so it takes precedent over other Javas you might have installed:


echo 'export PATH=/opt/java/64/jdk1.6.0_29/bin:$PATH' >> ~/.profile
Relaunch your terminal and test, java -version:


java version "1.6.0_29"
Java(TM) SE Runtime Environment (build 1.6.0_29-b11)
Java HotSpot(TM) 64-Bit Server VM (build 20.4-b02, mixed mode)
Building…


Follow Google’s Downloading the Source Tree, which will help you install the repo tool and clone the android-4.0.1_r1 branch. It’s damn near 9 gigabytes, so make sure you have a fast Internet pipe and a pot of coffee ready.


After that you’ll be ready to build:


cd ~/android/ics
lunch full-eng

make CC=gcc-4.4 CXX=g++-4.4 -j4


On my dual-core Core i7 Thinkpad T420 with 8GB of RAM this takes ~110 minutes, your mileage may vary depending on the number of available cores, amount of RAM, and speed of your hard drives.


If your build completes successfully you’ll be able to test it immediately using theemulator command (a version of QEMU, built as part of the build process):




Ice Cream Sandwich in the qemu emulator
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值