Sunday, 25 April 2010

Building Android in Debian Sid

We are going to build and test Android in Debian Sid on x86 32 bits architecture.

As a requirement we need JDK 5.0, update 12 or higher. Java 6 is not supported, because of incompatibilities with @Override.

Debian Sid provides all packages we need except this one. We could install from source but instead we are going to install JDK 5.0 from Debian Stable (Lenny) repositories:

ADD DEBIAN STABLE (LENNY) REPOSITORIES


#echo "deb http://ftp.debian.org/debian/ stable main contrib non-free" >> /etc/apt/sources.list

#aptitude update

sun-java5-jdk package will now become available.


INSTALL ALL PACKAGES WE NEED:


#aptitude 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


SELECT THE RIGHT JAVA VERSION:


$file /etc/alternatives/java* # To know which alternative files we have to update.
#update-alternatives --config java
#update-alternatives --config java_vm
#update-alternatives --config javaws


We also install valgrind, a tool that will help you find memory leaks, stack corruption, array bounds overflows, etc.
#aptitude install valgrind


Android projects are stored in Git repositories. Also they have developed a tool called REPO to facilitate working with git repositories.

INSTALLING REPO


You can install repo tool any place in your path. We choose a bin directory in our home folder:

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



DOWNLOADING ANDROID SOURCE CODE:


Create an empty directory to hold your working files:
$mkdir mydroid
$cd mydroid

# Run repo init to bring down the latest version of Android 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

NOTE: using -b option we can choose which android version to install:
$repo init -u git://android.git.kernel.org/platform/manifest.git -b eclair


To pull down files to your working directory from the repositories as specified in the default manifest, run
$repo sync


NOTE: mydroid directory size grows up to 3.6G.



BUILDING ANDROID


Simply on top of your android directory execute make command:
$cd mydroid
$make

After some time it will finish.

We get the installed file list in this file:
out/target/product/generic/installed-files.txt

Also some images are created in the same directory: (system.img userdata.img ramdisk.img)
mydroid$ ls out/target/product/generic/
android-info.txt  data                 obj                       ramdisk.img  symbols  system.img
clean_steps.mk    installed-files.txt  previous_build_config.mk  root         system   userdata.img



We have built android source code but now we want to test it:

ANDROID EMULATOR


We will run the Android Emulator, which comes within the Android SDK
http://developer.android.com/guide/developing/tools/emulator.html

Download Android SDK
http://developer.android.com/sdk/index.html

Install Android SDK
http://developer.android.com/sdk/installing.html

We untar the sdk and add tools directory into the PATH variable:
$tar xvzf android-sdk_r05-linux_86.tgz
$export PATH=$PATH:~/android-sdk-linux_86/tools


We are not going to create an android virtual device, but instead we will use an environment variable to indicate where our images are:


RUNNING ANDROID EMULATOR


$emulator -help # Shows some help.

$export ANDROID_PRODUCT_OUT=/path/to/mydroid/out/target/product/generic/ # Env variable showing where our images are.

We create a SD image to simulate a SD card:
$cd mydroid/out/target/product/generic/
$mksdcard -l SD 100M sdcard.img

Run the emulator program:
$emulator -verbose

if we want more debug information:
$emulator -show-kernel -verbose



CONNECTING TO THE EMULATOR USING ADB (ANDROID DEBUG BRIDGE) TOOL


adb tool comes within Android SDK.

In a console we execute:
$adb devices

It will show available devices in your system:
List of devices attached
emulator-5554   device

We can now connect to the device:
$adb shell


REFERENCE:

http://source.android.com/download

YOU MAY ALSO BE INTERESTED IN:

How to BUILD the LINUX KERNEL for the ANDROID EMULATOR (Eclair version)

1 comentarios:

erection pills viagra online said...

Hello to every , for the reason that I am really eager of reading this website's post to be updated regularly. It carries nice material.