Building Android 4.0 on Ubuntu 11.10, 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 no sun-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. Install it from ppa this way :
sudo add-apt-repository ppa:ferramroberto/java
sudo apt-get install sun-java6-jdk
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 the emulator command (a version of QEMU, built as part of the build process):
0 Komentar
Penulisan markup di komentar