2010年2月3日 星期三

Building Android platform with insufficient RAM

I was trying to build Android platform in my Ubuntu in VirtualBox, and met a problem. It might due to insufficient RAM.



==============================
Install the necessary tool chain, following the instructions here:
http://source.android.com/download

sudo apt-get install  git-core  gnupg  sun-java5-jdk  flex  bison  gperf  libsdl-dev  libesd0-dev  libwxgtk2.6-dev  build-essential  zip  curl  libncurses5-dev  zlib1g-dev


sudo apt-get install valgrind


==============================
mkdir ~/android_platform


curl http://android.git.kernel.org/repo > ~/bin/repo
chmod a+x ~/bin/repo
export PATH=~/bin:$PATH


cd ~/android_platform
repo init -u git://android.git.kernel.org/platform/manifest.git (-b eclair)
repo sync build
    (This downloads ./build/.., and copies ./build/core/root.mk to ./Makefile)


repo sync
    (Download all (3.5GB!))

============================
I thought I can use repo sync XXX to get only the projects I need.
But I met a problem like the one below:
make: *** No rule to make target `out/host/linux-x86/bin/acp’, needed by `out/target/product/generic/system/etc/apns-conf.xml’. Stop.
So, after googling a while I decided to get the full Android platform source.

============================

cd ~/android_platform
. build/envsetup.sh
    (Also set up some functions, e.g. m, mm, mmm, lunch, tapas)

==========================
(Install JDK...)
http://mmmyddd.freeshell.net/wiki/android/build.html
http://java.sun.com/javase/downloads/5u22/jdk (
2010/11/16: https://dct.sun.com/dct/forms/reg_us_0809_958_0.jsp)
    (jdk-1_5_0_22-linux-i586.bin --> jdk1.5.0_22/ --> /usr/local)
http://java.sun.com/javase/downloads (2010/11/16: http://www.oracle.com/technetwork/java/javase/downloads/index.html)
    (jdk-6u18-linux-i586.bin --> jdk1.6.0_18/ --> /usr/local)
ls ~/.bashrc
if [ 0 -eq 1 ]; then
  export JAVA_HOME=/usr/local/jdk1.5.0_22
else
  export JAVA_HOME=/usr/local/jdk1.6.0_18
fi
export PATH=$JAVA_HOME/bin:$PATH
export ANDROID_JAVA_HOME=$JAVA_HOME

====================


Start to build!
First:
cd ~/android_platform
make BUILD_TINY_ANDROID=true
    (Build minimal set, which is used for bring-up)

Build some libraries / applications:
cd ~/android_platform/frameworks/base/libs/utils
mm
cd ~/android_platform/frameworks/base/libs/binder
mm
cd ~/android_platform/external/wpa_supplicant
mm
cd ~/android_platform/hardware/libhardware_legacy
mm
cd ~/android_platform
mmm hardware/ril/libril hardware/ril/reference-ril hardware/ril/rild
ls out/target/product/generic/system/lib
ls out/target/produce/generic/system/bin
    (My original purpose was to build libreference-ril, libril, and rild)


Build them all~
cd ~/android_platform
export TARGET_ARCH=x86
lunch 1
make
    (Full build of generic-eng)
.
..
...
....
.....Oops!
================
I met a problem when doing full-build...

(When using JDK 1.5:)
Copying: out/debug/target/common/obj/JAVA_LIBRARIES/framework_intermediates/classes.jar
target Dex: framework
#
# An unexpected error has been detected by HotSpot Virtual Machine:
#
# SIGSEGV (0xb) at pc=0x4003d156, pid=16267, tid=2885839728
#
# Java VM: Java HotSpot(TM) Client VM (1.5.0_22-b03 mixed mode)
# Problematic frame:
# C [libpthread.so.0+0xa156] pthread_cond_timedwait+0x106
#
# An error report file with more information is saved as hs_err_pid16267.log
#
# If you would like to submit a bug report, please visit:
# http://java.sun.com/webapps/bugreport/crash.jsp
#
make: *** [out/debug/target/common/obj/JAVA_LIBRARIES/framework_intermediates/classes.dex] Aborted

(When using JDK 1.6:)
Copying: out/debug/target/common/obj/JAVA_LIBRARIES/framework_intermediates/classes-full-debug.jar
target Dex: framework
make: *** [out/debug/target/common/obj/JAVA_LIBRARIES/framework_intermediates/classes.dex] Killed

It seems my host machine doesn't have enough RAM:
http://groups.google.com/group/android-platform/browse_thread/thread/153e2155e33c6555

People say we need 10GB HDD space and 1.5GB RAM to build.
But I assigned only 0.5GB RAM for my Ubuntu 9.10 VirtualBox running on WinXP.



To be continued in next post...

沒有留言: