Pages

Get it free, Try now

Free Cell Phones

Thursday, December 30, 2010

How to get Base address/PHYS_OFFSET for specific hardware

::::Quick description:::
Search for PHYS_OFFSET  in .config if not See at kernel sources at the file: arch\arm\mach-msm\include\mach\memory.h

HTC- Buzz

/* physical offset of RAM */
#if defined(CONFIG_ARCH_QSD8X50)
#define PHYS_OFFSET        UL(0x20000000)
#elif defined(CONFIG_ARCH_MSM7225) // make sure CONFIG_ARCH_MSM7225 is set to 'y' in .config
#define PHYS_OFFSET        UL(0x02E00000)
#elif defined(CONFIG_ARCH_MSM7200A)
#define PHYS_OFFSET        UL(0x19200000)
#elif defined(CONFIG_ARCH_MSM7201A)
#define PHYS_OFFSET        UL(0x19200000)
#elif defined(CONFIG_ARCH_MSM7X00A) && defined(CONFIG_MACH_DESIREC)
#define PHYS_OFFSET        UL(0x11200000)
#elif defined(CONFIG_ARCH_MSM7X00A)
#define PHYS_OFFSET        UL(0x19200000)
#elif defined(CONFIG_ARCH_MSM7227)
#define PHYS_OFFSET        UL(0x12C00000)
#else
#define PHYS_OFFSET        UL(0x10000000)


For LG-GT540 Base address is PHYS_OFFSET  UL(0x00200000)

Tuesday, December 28, 2010

How to compile Android Device Driver as a Module(.ko)

Here are the quick steps to be followed.

Prerequisite:
1. kernel sources from vendor say HTC wildfire(2.1 update-1)
2. Android source code for Éclair
3. Create a new folder called Kernel and copy the contents from the sources download via vendor

Step1: Copy config.gz from running hardware

adb pull /proc/config.gz
gunzip config.gz
mv config .config


Step 2: Copy/Overwrite the .config file to the kenel root directory

open .config file and search for
CONFIG_MODULE_NAME1=y
CONFIG_MODULE_NAME2=y


and replace 'y' with 'm', we use CONFIG_MODULE_NAME1 as module

CONFIG_MODULE_NAME1=m
CONFIG_MODULE_NAME2=y

Step 3: Check the active kernel version on the hardware using 'OR' if you are using own Boot.img then skip this and move on to step 4:

adb shell
# uname -a

or you may get the details of the kernel from the Settings->Aboutphone->SoftwareInformation: Kernel version

2.6.29-6fb59e13 HTC-kernel@xxxxxxxx

open Makefile in the kernel folder, search and replace "EXTRAVERSION =" with "EXTRAVERSION =-6fb59e13"

Step 4: Set the Env variables

export ARCH=arm
exprot CROSS_COMPILE=arm-eabi-
export PATH=$PATH:~/eclair/prebuilt/linux-x86/toolchain/arm-eabi-4.4.0/bin/


now perform make modules for make from the kernel sources

kernel:$ make modules or make

after successful compilation, check out the .ko files next to the sources in the same directory

Complete example: How to get LG headset sources compile in to kernel module(.ko)

How to get LG headset sources compile in to kernel module(.ko).

This article is about compiling specific sources into Kernel Module in Android, read this first before you proceed further

I have taken Headset Driver as a use case.

1. Create a folder headset_lg at location: ~/gt540_2.1/kernel/arch/arm/mach-msm/headset_LG

2. Copy board-swift-headset.c from ~/gt540_2.1/kernel/arch/arm/mach-msm/swift to headset_LG folder and make changes to it below

change //static int __init lge_hsd_init(void) to static int lge_hsd_init(void)
change // actuall call is static void __exit lge_hsd_exit(void) to static void lge_hsd_exit(void)
also comment this line
//device_initcall(hsd_debug_init);

write make file to compile the .c file

makefile
#
# Makefile for the swift specific files
#


#obj-y += board-swift-bl-rt9393.o
obj-m = board-swift-headset.o // replace obj-y to obj-m // were m stand for Module

3. also change need to be made inside /home/br/gt540_2.1/kernel/arch/arm/mach-msm/rpc_server_misc.c

comment the global variable "headset_inserted" which is used to udpate the status of actual hardware

4. change to root folder of the kernel and run make. you shall see the .ko file at location given below
 Kernel: arch/arm/boot/Image is ready
Kernel: arch/arm/boot/zImage is ready
Building modules, stage 2.
MODPOST 16 modules
LD [M] arch/arm/mach-msm/headset_LG/board-swift-headset.ko

Installing Kernel Module

~/arch/arm/mach-msm/headset_LG/$adb push /sdcard/board-swift-headset.ko
~/arch/arm/mach-msm/headset_LG/$adb shell
$su
# insmod /sdcard/board-swift-headset.ko //dont panic, filesystem should restart after executing insmod stmt
# lsmod // to verify the driver
# rmmod board-swift-headset.ko // to remove kernel module

Tuesday, December 14, 2010

Android - Accessing Input device "msm_pcm_in" from User space

This article shows code snippet on how to access input device driver from user space.

Recording from input device (msm_pcm_in: a char Device Driver) follows the below events

Open device :

int ret = open("/dev/msm_pcm_in", O_RDWR); // open device

struct msm_audio_config confg;

ioctl(ret, AUDIO_GET_CONFIG, &confg) // this call fill the structure with default driver values.


cfg.channel_count = 1; // assign new number of channel(1= mono, 2 = stereo)
cfg.sample_rate = 8000;// assign sampling rate such as 8000 or 16000,.....
int val = ioctl(ret, AUDIO_SET_CONFIG, &confg);// set the new audio configuration


Before we being to start audio read/write operations, create a file to store buffers
const char *fn = /sdcard/tmp/file1;
int file = open(fn, O_CREAT | O_RDWR, 0666);

bool isrecording = true; // use this flag to stop recording (true default, false to disable reading)

ioctl(ret, AUDIO_START, 0);





fcntl(0, F_SETFL, O_NONBLOCK);// provides control of open file descriptors.

unsigned char buf[4092];

for (;;) {
while (!isrecording) {
// close all file descriptors and exit
}
if (read(ret, buf,confg.buffer_size ) != confg.buffer_size) {
// if fail to read
// close all file descriptors and exit
}

if (write(file, buf, confg.buffer_size) != confg.buffer_size) {
// if fail to read
// close all file descriptors and exit
}

}




Close device:


close(ret);
...
...
close (file);



Note: To run this as a recorder app, make sure you have root privileges.

Friday, December 10, 2010

Android- How to Create Executable

1. Setup ndk project with android.mk and native sources

Android.mk file should include BUILD_EXECUTABLE, sample android.mk is below.


LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)

LOCAL_MODULE := Modulename
LOCAL_SRC_FILES := file1.c\
file2.c

LOCAL_MODULE_TAGS := optional
include $(BUILD_EXECUTABLE)


2. Building executable.

$ ndk-buld

3. Run executable

copy to device say /sdcard/data/Modulename
xxxx@xx:$> adb shell
$./sdcard/data/Modulename


Note:Make sure you place Android.mk file along with source(c/c++) in same folder and name it as jni. as libs and obj folders are created next to jni folder.

Friday, November 19, 2010

Android - Manual SD Card partions vfat and ext2

we will first check if there are any partitions on the sdcard,if there any we will set it to unpartitioned state...
below steps are command base you may use the GUI software Gparted to do the same.

Disclaimer: I AM NOT RESPONSIBLE FOR WHAT YOU DO WITH YOUR DEVICE


1. Read the sdcard partions(shows devices connected)
#cat /proc/partitions
major minor #blocks name


8 0 156290904 sda
8 1 102400 sda1
8 2 104985600 sda2
8 32 312571224 sdc
8 33 226298554 sdc1
8 34 1 sdc2
8 37 82715648 sdc5
8 38 3555328 sdc6
8 16 488386584 sdb
8 17 102398278 sdb1
8 18 1 sdb2
8 21 20482843 sdb5
8 48 1921024 sdd // see some hardware connected
8 49 1920000 sdd1 // ID of the HW

2. Very again, if they are mounted using mount command and we see that there is a Linux partition of type ext2
# mount
blah ...
....
/dev/sdd1 on /media/61de92d5-99ae-48e7-9c14-0fa3f86c2d93 type ext2 (rw,nosuid,nodev,uhelper=udisks)

3. unmount the drive
# umount /dev/sdd1
#

4.Now we will remove the already available partitions and create two new partition of type FAT32 and ext2. follow the warning from command to get rid any unknown issues



#fdisk /dev/sdd

WARNING: DOS-compatible mode is deprecated. It's strongly recommended to
switch off the mode (command 'c') and change display units to
sectors (command 'u').

Command (m for help): c
DOS Compatibility flag is not set

Command (m for help): u
Changing display/entry units to sectors

Command (m for help): m
Command action
a toggle a bootable flag
b edit bsd disklabel
c toggle the dos compatibility flag
d delete a partition
l list known partition types
m print this menu
n add a new partition
o create a new empty DOS partition table
p print the partition table
q quit without saving changes
s create a new empty Sun disklabel
t change a partition's system id
u change display/entry units
v verify the partition table
w write table to disk and exit
x extra functionality (experts only)

Command (m for help): p

Disk /dev/sdd: 1967 MB, 1967128576 bytes
54 heads, 32 sectors/track, 2223 cylinders, total 3842048 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00026cc2

Device Boot Start End Blocks Id System
/dev/sdd1 * 2048 3842047 1920000 83 Linux

Command (m for help): d // delete 1st partition
Selected partition 1

ommand (m for help): n // type n for new partition
Command action
e extended
p primary partition (1-4)
p
Partition number (1-4): 1
First sector (32-3842047, default 32):
Using default value 32 // 1st partition starts after 32 till 3842047
Last sector, +sectors or +size{K,M,G} (32-3842047, default 3842047): 2000000 // we use only half of the value

Command (m for help): p

Disk /dev/sdd: 1967 MB, 1967128576 bytes
54 heads, 32 sectors/track, 2223 cylinders, total 3842048 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00026cc2

Device Boot Start End Blocks Id System
/dev/sdd1 * 32 2000000 999984+ c W95 FAT32 (LBA)

Command (m for help): t // change type of partitions
Selected partition 1 // apply for 1st partition
Hex code (type L to list codes): 83 // 83 corresponds to Linux id
Changed system type of partition 1 to 83 (Linux)

Command (m for help): p // type p, shall results in partition of type Linux

Disk /dev/sdd: 1967 MB, 1967128576 bytes
54 heads, 32 sectors/track, 2223 cylinders, total 3842048 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00026cc2

Device Boot Start End Blocks Id System
/dev/sdd1 * 32 2000000 999984+ 83 Linux
//repeat steps to create new partions
//
Command (m for help): n
Command action
e extended
p primary partition (1-4)
p
Partition number (1-4): 2 // 2nd partition
First sector (2000001-3842047, default 2000001):
Using default value 2000001 // allocation start here and ends at 3842047
Last sector, +sectors or +size{K,M,G} (2000001-3842047, default 3842047):
Using default value 3842047

Command (m for help): p

Disk /dev/sdd: 1967 MB, 1967128576 bytes
54 heads, 32 sectors/track, 2223 cylinders, total 3842048 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00026cc2

Device Boot Start End Blocks Id System
/dev/sdd1 * 32 2000000 999984+ 83 Linux
/dev/sdd2 2000001 3842047 921023+ 83 Linux

Command (m for help): t // type t to change 2nd partitio to windows type
Partition number (1-4): c // typeo err
Partition number (1-4): 2 //
Hex code (type L to list codes): c // ID for windows type
Changed system type of partition 2 to c (W95 FAT32 (LBA))

Command (m for help): p // type p

Disk /dev/sdd: 1967 MB, 1967128576 bytes
54 heads, 32 sectors/track, 2223 cylinders, total 3842048 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00026cc2

Device Boot Start End Blocks Id System
/dev/sdd1 * 32 2000000 999984+ 83 Linux
/dev/sdd2 2000001 3842047 921023+ c W95 FAT32 (LBA)

// finally, we created two partions 1st linux and 2nd windows
// now we need to write the table to disk and exit
// type w
Command (m for help): w
The partition table has been altered!


Calling ioctl() to re-read partition table.

WARNING: If you have created or modified any DOS 6.x
partitions, please see the fdisk manual page for additional
information.
Syncing disks.

~???#

now we need to format tables inthe disk, i;e make filesystem
#mkfs.vfat /dev/sdd2
mkfs.vfat /dev/sdd2
#
#root@br-desktop:/home/br# mkfs.ext2 /dev/sdd1
mke2fs 1.41.11 (14-Mar-2010)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
Stride=0 blocks, Stripe width=0 blocks
62592 inodes, 249996 blocks
12499 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=260046848
8 block groups
32768 blocks per group, 32768 fragments per group
7824 inodes per group
Superblock backups stored on blocks:
32768, 98304, 163840, 229376


Writing inode tables: done
Writing superblocks and filesystem accounting information: done

This filesystem will be automatically checked every 31 mounts or
180 days, whichever comes first. Use tune2fs -c or -i to override.
// now unplug and plugin the sdcard and type Mount on the terminal, shall show you this
#
#
#mount
....
...
/dev/sdd1 on /media/2b3f5798-9c5f-4ce3-8275-c7c987b0764c type ext2 (rw,nosuid,nodev,uhelper=udisks)
/dev/sdd2 on /media/79BF-0782 type vfat (rw,nosuid,nodev,uhelper=udisks,uid=1000,gid=1000,shortname=mixed,dmask=0077,utf8=1,flush)

Technicalities to build custom ROM for LG GT540

::First things first::

Thanks to XDA developer and Modaco forums to share their experience

Below are the steps taken by me to build a working Android kernel image and system image for the GT540 (a.k.a. LG SWIFT). This image is based on linux kernel 2.6.29 and relies on the Android 2.1 "Eclair".

This page is here as a reminder to me for when I come to do it again. This is what worked for me so far, your approach may vary.



1. Download required tools and software

-Download GT540 ROM sources from LG here.

I have used Eclair sources, the size should be 132MB after download. next unzip sources and follow the Readme.txt to ease I copy-paste below
1. How to download Android source.

refer to Android site - http://source.android.com/source/download.html

2. Check your build environment

whether it is successful in building downloaded Android source.

3. Untar open source package of GT540 into downloaded Android source

4. Kernel Build

dount$> source ./build/envsetup.sh

donut$> choosecombo 1 1 generic 1

donut$> cd kernel

donut/kernel$> make swift_defconfig

donut/kernel$> make

-> After build, you can find the built image at kernel/arch/arm/boot/

5. Android Source Build

donut$> source ./build/envsetup.sh

donut$> choosecombo 1 1 generic 1

donut$> make

-> After built, you can find the built image at out/target/product/generic

-Download Android source code for desired version like Eclair in this case, Details on how to download source code is here

2. Build kernel and system images

-Following the first steps in Readme.txt from LG sources will give you the kernel image i;e zImage at ~/eclair/kernel/arch/arm/boot/zImage

-Second step will build system.img, ramdisk.img, userdata.img which will be at ~home/br/eclair/out/target/product/generic/

you may run system.img to test on emulator(How to is here ) before NAND flashing

3. Unpack, Repack and Flashing

- Get the Boot image from existing target

 

# cat /proc/mtd

dev: size erasesize name

mtd0: 00500000 00020000 "boot"

mtd1: 04000000 00020000 "cache"

mtd2: 00500000 00020000 "recovery"

mtd3: 00060000 00020000 "splash"

mtd4: 0f500000 00020000 "system"

mtd5: 002c0000 00020000 "lgdrm"

mtd6: 08b80000 00020000 "userdata"

mtd7: 00080000 00020000 "usd"

mtd8: 005a0000 00020000 "pkg"

mtd9: 1cfc0000 00020000 ""

# cat /dev/mtd/mtd0 > /sdcard/boot.img pull the boot.img from sdcard and apply below scripts

- Download scripts from here (follow the instruction in the scripts) to add new kernel image with devicee ramdisk. I have a different set of scripts that I will share later.

- Used fastboot to flash images, fastboot usage is here

-First reboot may take while, or you may see weird behavior (stuck at boot screen or reboot loop.....)

Conclusion: Kernel up and running, but system image give a problem...

 

P.S : Dear readers, if you are able to run custom system image please do share your experiences.

Thursday, November 11, 2010

Android: make the system partitions on the device read-write

From the SDK's tools directory, run adb shell. In the
prompt run the following:

# su
# mount -o rw,remount -t yaffs2 /dev/block/mtdblock4 /system
# chmod 777 /system (Or any subdirectory you want to push to inside system)
# exit
adb push

and eventually you should restore the original directory permissions by:
# chmod 755 /system (Or any subdirectory you modified permissions to)

Make sure you knew the mount point for system by running #
# cat /proc/mtd
dev: size erasesize name
mtd0: 00500000 00020000 "boot"
mtd1: 04000000 00020000 "cache"
mtd2: 00500000 00020000 "recovery"
mtd3: 00060000 00020000 "splash"
mtd4: 0f500000 00020000 "system"
mtd5: 002c0000 00020000 "lgdrm"
mtd6: 08b80000 00020000 "userdata"
mtd7: 00080000 00020000 "usd"
mtd8: 005a0000 00020000 "pkg"
mtd9: 1cfc0000 00020000 ""

Wednesday, November 10, 2010

How to Build a single module in Android and include in System image

Go to build directory under Android sources
Execute source ./envsetup.sh
Go to corresponding application directory (~/eclair/hardware/msm7k/libaudio$)
Issue mm command to build the Module only in this case its libaudio.so

if you want to include in system.img in conjunction with ROM sources from vendor

run make from the root directory

~/eclair$ make
============================================
PLATFORM_VERSION_CODENAME=REL
PLATFORM_VERSION=2.1-update1
TARGET_PRODUCT=generic
TARGET_BUILD_VARIANT=eng
TARGET_SIMULATOR=
TARGET_BUILD_TYPE=release
TARGET_ARCH=arm
HOST_ARCH=x86
HOST_OS=linux
HOST_BUILD_TYPE=release
BUILD_ID=ECLAIR
============================================
build/core/copy_headers.mk:15: warning: overriding commands for target `out/target/product/generic/obj/include/libpv/getactualaacconfig.h'
build/core/copy_headers.mk:15: warning: ignoring old commands for target `out/target/product/generic/obj/include/libpv/getactualaacconfig.h'
Install: out/host/linux-x86/lib/libneo_util.so
...
...
...
Install system fs image: out/target/product/generic/system.img
~/eclair$

Running Android emulator up with custom system image

1.Run Terminal, and change to the 'tools' directory of the SDK
2.Type './android list target'
3.Note the 'id' number of the '2.1' target (in my case it's '7')
4.Type './android create avd -n eclair -t 7' (where 7 with the target number determined above if required)
5.You will be prompted to create a hardware profile. say YES and provide user defined values or leave as default.
6.Copy system.img to ~/.android/avd/eclair.avd/system.img
7.Type './emulator -avd eclair' command to run emulator with system.img! Note: initial boot may take a few minutes!

should you get any Java issues download the JDK for your system "jdk-6u14-windows-i586.exe"

how to use fastboot on Ubuntu

1.Download fastboot from here

OR you could the one from the android sources at location ~/eclair/out/host/linux-x86/obj/EXECUTABLES/fastboot_intermediates/fastboot
2.Move it sdk "tools" folder and enable root permissions
3.Make sure you add vendor id to the 51.android.rules file and set a+rx permissions and reboot(more details on setting vendor id is here )
4.Reboot in fastboot mode(each individual hardware has it own keyspress to boot into bootloader) then connect USB cable and issue below command

$./fastboot devices
??????? fastboot


quick usage


$./fastboot -w
$./fastboot erase system
$./fastboot flash system system.img
$./fastboot flash boot boot.img
$./fastboot reboot

Tested on LG GT540

Note: No idea why it shows ???? indeed vendorid is povided already.

Wednesday, October 13, 2010

Porting Android to beagle broad for Noob

Primarily I would suggesst to take a look at

http://labs.embinux.org/index.php/Main_Page

then

http://www.codeshogun.com/blog/2009/04/15/porting-android-to-beagle-board/

Thursday, October 7, 2010

Android NDK Error Reference for noob

Android NDK Error Reference

Error 1:
$ ndk-build
/cygdrive/c/andy/abc/obj/local/armeabi-v7a/objs/abc//hellow.o.d:1: *** multiple target patterns. Stop.

quick fix: Delete Obj folder from "C:\andy\prjM\obj\local\armeabi-v7a" then run ndk-build
or refer this

Error 2:
Android.mk:44: *** commands commence before first target. Stop.
fix: Check there are no comments,no space ,no empty line in the src includes of Android.mk

For example:
wrong:
LOCAL_SRC_FILES :=file1.cpp\
file1al.cpp\
#file1atures.cpp\
file1r.cpp\

file1le.cpp\
Satfile1.cpp\
Sfile1l.cpp\
file1e.cpp\
Sfile1face.cpp\

3rd line has #, 4th line has space(check with cursor),5th line is empty line

Right:
LOCAL_SRC_FILES :=file1.cpp\
file1al.cpp\
file1atures.cp\
file1r.cpp\
file1le.cpp\
Satfile1.cpp\
Sfile1l.cpp\
file1e.cpp\
Sfile1face.cpp\

Error 3:
$ ndk-build clean
Android NDK: Could not find application project directory !
Android NDK: Please define the NDK_PROJECT_PATH variable to point to it.
/cygdrive/c/android-ndk-r4b/build/core/build-local.mk:85: *** Android NDK: Aborting . Stop.

Fix: include Android.mk location inside global application.mk and Android.mk
Run the command from the parent directory with app.mk and and.mk resides

Error 4:

Please define ANDROID_NDK_ROOT to point to the root of your
Android NDK installation.

Use case while executing shell script

xxx-desktop:~/bin/u/android-ndk-r5/build/tools$ ./rebuild-all-prebuilt.sh
Please define ANDROID_NDK_ROOT to point to the root of your
Android NDK installation.

// Run the script inside NDK root directory like shown below
xxx-desktop:~/bin/u/android-ndk-r5/build/tools$ cd ..
xxx-desktop:~/bin/u/android-ndk-r5/build$ cd ..
xxxx-desktop:~/bin/u/android-ndk-r5$ ./build/tools/rebuild-all-prebuilt.sh

Error 5: NDK r5 app(native-activity,native-audio,native-plasma) build problem

Compiling native-activity,native-audio,native-plasma on ndk-r5 give compile errors stating

header not found and  so on ......

Quick fix:  Rebuild all prebuilt

i;e execute shell script rebuild-all-prebuilt.sh to build on latest toolchain provided by android which will take for a while (atleast on my pc)

xxx-desktop:~/bin/u/android-ndk-r5$ ./build/tools/rebuild-all-prebuilt.sh
To follow build in another terminal, please use: tail -F /tmp/ndk-toolchain/build-CtAG7s/log.txt
Download sources from android.git.kernel.org
Using git clone prefix: git://android.git.kernel.org/toolchain
downloading sources for toolchain/binutils
downloading sources for toolchain/build
downloading sources for toolchain/gcc
downloading sources for toolchain/gdb
downloading sources for toolchain/gmp
downloading sources for toolchain/gold
downloading sources for toolchain/mpfr
Patching toolchain sources
Toolchain sources downloaded and copied to /tmp/ndk-toolchain/build-CtAG7s/src
Cleaning up...
Done.
Building arm-eabi-4.4.0 toolchain... (this can be long)
ERROR: Could bot build arm-eabi-4.4.0 toolchain!
xxxx-desktop:~/bin/u/android-ndk-r5$

Now change to native-activity folder and call ndk-build for successful libnative-activity.so

xxx-desktop:~/bin/u/android-ndk-r5/samples/native-activity$ ndk-build
Compile thumb  : native-activity <= main.c
Compile thumb  : android_native_app_glue <= android_native_app_glue.c
StaticLibrary  : libandroid_native_app_glue.a
SharedLibrary  : libnative-activity.so
Install        : libnative-activity.so => libs/armeabi/libnative-activity.so

*** multiple target patterns issue in Cygwin

follow the discussion in the 2nd reply from the board message here

http://www.eclipse.org/forums/index.php?t=msg&goto=188883&


*EDIT* seem the updated eclipse forum moved the board message, a quick fix is try to update make with latest version shall fix *** multiple target patterns issuee

Tuesday, October 5, 2010

Integrate Android NDK with Eclipse

Its assume that both NDK and cygwin are installed on same location

C:\cygwin
C:\android-ndk-r4b

we will use hello-jni project from the samples provided with NDK,
C:\android-ndk-r4b\samples\hello-jni

Import the project inside Eclipse
Click project properties.
Select "builders" from the left-hand list.
Click on button "New..." on the right side.
Select "Program" as the configuration type.
Name it as you like say "Build_JNI"
In 'Main' tab enter
Location as -

c:\cygwin\bin\bash.exe



Working Directory as -

c:\cygwin\bin



Arguments as


--login -c "cd /cygdrive/c/android-ndk-r4b/samples/hello-jni && ndk-build -B"




Make sure you have the two hyphens before login and the quotes after the hyphen-c

Now go to the 'Refresh' tab
Check "Refresh resources upon completion"
Select "Specific resources"
Click on the "Specify resources" button and select your project's lib directory.
Check "Recursively include sub-folders"

Now go to the 'Build Options' tab

Check "Allocate Console"
Check "Launch in background"
Check "Run the builder After a Clean"
Check "Run the builder During manual builds"
Check "Run the builder During auto builds"
Check "Specify working set of relevant resources"
Click on "Specify Resources"
Select your project's JNI directory and all files within.


finally click Apply n OK

Check slide show for LAF
[slideshow]

Monday, October 4, 2010

how to use Logs in Android Application and Android NDK

We will first see how to use logs on Android Application side and then we look into usage of logs on Native side(NDK)

On Application side
Import log provided by Android
import android.util.Log;

then use below two lines of code where ever needed
String TAG ="ModuleName";
Log.d(TAG,"File Name is =%s"+ testFilename );

Use following based on the priority constants

Priority Usage

DEBUG Log.d
ERROR Log.e
INFO Log.i
VERBOSE Log.v
WARN Log.w
WTF Log.wtf

WTF(What a Terrible Failure): Report an exception that should never happen.

Inside Native code
Similarly in Native code include the header and call the ' __android_log_print' , '__android_log_write' with appropriate priority constants, do not miss to the library in the Android.mk fail to which leads to linker issues.

Add below line in Android.mk
......
LOCAL_LDLIBS := -llog
....

Include header
...
#include "android/log.h"
....
then call
{..
__android_log_print(ANDROID_LOG_INFO, "ModuleName FunctionName", "Enter");
...
...
__android_log_print(ANDROID_LOG_INFO, "ModuleName FunctionName", "Exit");
}


or
{
__android_log_write(ANDROID_LOG_ERROR, "ModuleName FunctionName", "#1");
....
}

use below priority constants or find directly under 'C:\android-ndk-r4b\build\platforms\android-8\arch-arm\usr\include\android'
ANDROID_LOG_UNKNOWN = 0,
ANDROID_LOG_DEFAULT, /* only for SetMinPriority() */
ANDROID_LOG_VERBOSE,
ANDROID_LOG_DEBUG,
ANDROID_LOG_INFO,
ANDROID_LOG_WARN,
ANDROID_LOG_ERROR,
ANDROID_LOG_FATAL,
ANDROID_LOG_SILENT,

Monday, September 27, 2010

How to Analyse Stack trace on Android

This article involves on how to Analyze stack trace on ANDROID, although there are tools available on how to make analysis on stack trace but I personally followed the below procedure.

1. Take a object dump of the the library(.so) using provided android tools


C:\android-ndk-r4b\build\prebuilt\windows\arm-eabi-4.2.1\bin>arm-eabi-objdump -S C:\andy\workspace\aolqaOEM\obj\local\armeabi-v7a\libaolqaWrapperDll.s
o > aolqalib.asm



OR


C:\android-ndk-r4b\build\prebuilt\windows\arm-eabi-4.2.1\bin>arm-eabi-objdump -dR C:\andy\workspace\aolqaOEM\obj\local\armeabi-v7a\libaolqaWrapperDll.s
o > aolqalib.asm




aolqalib.asm is now disassembled, which mean you are now able to trace address assigned to each function in the library.

2. Copy aside the stack trace from the log-cat view of carbide.
*** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
Build fingerprint: 'google/passion/passion/mahimahi:2.2/FRF91/43546:user/release-keys'
pid: 864, tid: 872 >>> xyz <<<
signal 11 (SIGSEGV), fault addr 002b3000
r0 47c23f10 r1 002b2fe8 r2 000b9e01 r3 00000008
r4 47ba9008 r5 00134d49 r6 002380c0 r7 80a4b724
r8 00000001 r9 474ea970 10 00291bf8 fp 0013f200
ip 00000000 sp 474ea320 lr afd1d56d pc afd0f1bc cpsr 20000010
d0 643a64696f72646e d1 6472656767756265
d2 0000002800000000 d3 0000000000000000
d4 0000000000000000 d5 0000000000000000
d6 0000000000000000 d7 0000000000000000
d8 46fdf80042e00000 d9 0000000000000000
d10 0000000000000000 d11 0000000000000000
d12 0000000000000000 d13 0000000000000000
d14 0000000000000000 d15 0000000000000000
d16 8000000000000000 d17 7e37e43c8800759c
d18 4085600000000000 d19 bfad7afccc419668
d20 4000000000000000 d21 3f114affd5703473
d22 bebbaaebd181c43f d23 3fd48e703a724000
d24 3e66376972bea4d0 d25 bff0000000000000
d26 3ff1687200000000 d27 bfad7afccc419669
d28 bffb22b279caa806 d29 3fd48e70431efbb1
d30 3c591e88027bf155 d31 3e41597762000000
scr 20000012
#00 pc 0000f1bc /system/lib/libc.so
#01 pc 0001d56a /system/lib/libc.so
#02 pc 0000fccc /data/data/xyz/lib/libaolqaWrapperDll.so
code around pc:
afd0f19c f5d1f000 f5d1f040 e2522040 3a000009
afd0f1ac f5d1f080 f5d1f0c0 f5d1f100 f421020d
afd0f1bc f421420d f5d1f100 e2522040 f400022d
afd0f1cc f400422d 2afffff8 e2822040 e2522020
afd0f1dc 3a000003 f421020d e2522020 f400022d
code around lr:
afd1d54c bf00e7ee 4606b570 ef5cf7f1 46281c45
afd1d55c fbdcf7ef b1184604 462a4631 edeaf7f1
afd1d56c bd704620 bf004b06 b510a200 189b4c05
afd1d57c 7280f44f 4621191c f840f000 bd104620
afd1d58c 00024db0 000022ac b5f02800 b085460c
stack:
474ea2e0 00000001
474ea2e4 474ea970
474ea2e8 00291bf8 [heap]
474ea2ec afd0c6c7 /system/lib/libc.so
474ea2f0 80a45141 /data/data/xyz/lib/libaolqaWrapperDll.so
474ea2f4 474ea844
474ea2f8 00000011
474ea2fc 00000032
474ea300 80a4b724 /data/data/xyz/lib/libaolqaWrapperDll.so
474ea304 afd0cd31 /system/lib/libc.so
474ea308 474ea844
474ea30c 80a4b7a8 /data/data/xyz/lib/libaolqaWrapperDll.so
474ea310 00134d49 [heap]
474ea314 002380c0 [heap]
474ea318 df002777
474ea31c e3a070ad
#00 474ea320 47ba9008
474ea324 afd1d56d /system/lib/libc.so
#01 474ea328 80bb8250 /data/data/xyz/lib/libaolqaWrapperDll.so
474ea32c 80a405d9 /data/data/xyz/lib/libaolqaWrapperDll.so
474ea330 002380c0 [heap]
474ea334 80a0fcd1 /data/data/xyz/lib/libaolqaWrapperDll.so

3. Now look at the last function call from user defined library in ourcase its libaolqaWrapperDll.so, the program counter (pc) value is 0000fccc, which triggers the next function call in libc.so @pc value 0001d56a and which in turn call another function @pc value 0000f1bc in libc.so.

Open the disassembled file and try to find the first PC value i,e 0000fccc exclude zeros before find only 'fccc' without inverted commas will fetch you something like this
fcc2: 980f ldr r0, [sp, #60]
fcc4: f8cd 3510 str.w r3, [sp, #1296]
fcc8: f8cd 3514 str.w r3, [sp, #1300]
fccc: f7fd fc64 bl d598
fcd0: f8dd 353c ldr.w r3, [sp, #1340]
fcd4: f50d 6ca6 add.w ip, sp, #1328 ; 0x530

if you scroll upwards you will find function call starting from 0000f8d0 which is the address assigned to function in library,so the function 0000fccc is called inside this method.
...
.............
............
0000f8d0 :
f8d0: e92d 4ff0 stmdb sp!, {r4, r5, r6, r7, r8, r9, sl, fp, lr}
f8d4: ed2d 8b02 vstmdb sp!, {d8}
f8d8: f5ad 6da8 sub.w sp, sp, #1344 ; 0x540
f8dc: b081 sub sp, #4
f8de: 4cc6 ldr r4, [pc, #792] (fbf8 )
f8e0: af34 add r7, sp, #208
...
....
...

now call on function indicates clearly that the crash was somewhere inside SetToCString method of CNewStdString.

Hope this helps, next session will try to write an article on how to hide function address inside .so file

Wednesday, September 22, 2010

Using AsyncTasks in Android

AsyncTasks, why do we need it?

As we are aware that any User interaction on any Android application should and must response with in 5 seconds, failure to which results in ANR Dialog. Yes "Application Not Responding" Dialog with 'Wait' and 'Force Close' inputs. Asynchronous operations can also be performed using Threads in accordance with Handler and messages to update UI about the action progress.

Here we will discuss code snippets on how AsyncTask can be incorporated to perform Synchronous operations updated the progress of operation.

Three types are used by AsyncTask, in this case datatype is a String,

AsyncTask
First param String, this type of the parameters sent to the task upon execution.
Second param , this type of the Strings contains progress units published during the background operation.
Third param Result, this strings contains the result of the background operation.

Note* when no params are required use type void.


A class extend AsyncTask which triggers/perform long running tasks along side in override methods of AsyncTasks.
such as in our case
1. doInBackground(...)
2. onPreExecute()
3. rogressUpdate(...)
4. onCancelled()
5. onPostExecute(...)
Note* '...' denotes function parameters

when myClass issues call to execute(...)

...
...
myClass.execute("String"); //where "String" is the first param of the AsyncTask function call.
.....
...
..
myClass.cancel(true);// onCancelled() is called.
.....




below we will see the intention of each function call

protected class myClass extends AsyncTask
{

// Note that first param in the class definition matches the param passed to this method
// and the last param in the class definition matches the return type of this method
@Override
protected String doInBackground( String... params )
{
//-- on every iteration
//-- runs a while loop that causes the thread to sleep for 50 milliseconds
//-- publishes the progress - calls the onProgressUpdate handler defined below
//-- and increments the counter variable i by one
for(int i=0; i<=n; i++)
{
// longrunningtask();
publishProgress( i );
}

return "TASKCOMPLETED";
}

//when user issues a cancel on the operation.
@Override
protected void onCancelled() {
// Do a cleanup on operation canceled
// ReInitialise Data
super.onCancelled();
}

// on successful completion of onPostExecute method is called
@Override
protected void onPostExecute(String result) {

//showResults();
//progressDialog.dismiss();

super.onPostExecute(result);

}
// Called before doInBackground()
@Override
protected void onPreExecute() {
super.onPreExecute();
// do any initialization
}

// update the UI on complete of longrunningtask()
@Override
protected void onProgressUpdate(String... values) {
super.onProgressUpdate(values);
}

}





Next article will follow on Services in Android.

Thursday, September 16, 2010

“Phone Number Lookup” for Android phones

A small tiny Android application "Phone Number Lookup".
[gallery]
This application addresses partial feature which native android contacts app don't have.

"Phone NumberLookup", is a very tiny app which find the name for the corresponding number entered in the search box. wondering why would one need this feature?
ever had a look at telephone/mobile monthly invoice [slideshow]which shows only the dialed numbers not dialed names.

when users want to know which dialed number belongs to whom then open "Phone Number Lookup" enter the number n hit the Lookup button and there you go...

isn't this application simple and very useful

Checkout the screen shots from Google's Nexus One device.
aNrstr = "11833";
ListView lw = (ListView) findViewById(R.id.ListView01);

if(aNrstr.length()>0){
ContentResolver cr = getContentResolver();
Uri uri = Uri.withAppendedPath(PhoneLookup.CONTENT_FILTER_URI, Uri.encode(aNrstr));
Cursor cursor = cr.query(uri, null, null, null,null);

startManagingCursor(cursor);
String[] from = { PhoneLookup.NUMBER, PhoneLookup.DISPLAY_NAME};
int[] to = { R.id.textValue, R.id.textName};

SimpleCursorAdapter adapter = new SimpleCursorAdapter(this, R.layout.row, cursor, from, to);
lw.setAdapter(adapter);

Tuesday, August 17, 2010

How to build shared/static library (.so file) on android.

Build Environment
1. Install Cygwin
2. Have javac which is already available in JDK package.
3. Install Android NDK(Native development Kit)
4. Make sure both cygwin and NDK are in same location such as
C:\android-ndk-r4\ and C:\cygwin

Now create a android project using eclipse or use samples folder instead C:\android-ndk-r4\samples

1.now, run through cmd, javac on .java file which has definition of native method and a static system method which loads library
//speaktoc.java
public class SpeaktoC {
public  native String showstring(String astr);
static{
System.loadLibrary("CallCodeasLIB");
}
}
i;e in my case
C:\android-ndk-r4\samples\JnihelloJni\src\ex\jnihellojni>javac SpeaktoC.java

results in SpeaktoC.class.

2. move to bin folder and execute javah command i;e
C:\android-ndk-r4\samples\JnihelloJni\bin>javah -jni ex.jnihellojni.SpeaktoC

resutls in  ex_jnihellojni_SpeaktoC.h

3. Create jni folder in project and copy the above generated header file.

4. Create a .c file and implement the methods generated in the .h file.
5. Dont forget to write android.mk file(check out this for Android.mk structure)
6. Now launch Cywgin and change the current directory to project folder i,e
type the following commands
$ cd /cygwin/c/android-ndk-r4/samples/JnihelloJni
and issue Build command
$ ../../ndk-build.
resuls
SharedLibrary : libcallcodeasLib.so in JnihelloJni/libs/armeabi

7. now call the exported method in the application as shown  below
SpeaktoC c = new SpeaktoC();
String str = c.showstring(); // methos is in Library

Compile Static Library only using NDK

In order to build Static library only follow the below steps

If you have multiple libs to build then make Android.mk file for each library  and call those .mk files in the root Android.mk file. On how to write Android.mk file refer Android NDK docs folder

1.    xxxxx/jni/lib1/Android.mk



LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)

LOCAL_MODULE    :=lib1

LOCAL_SRC_FILES :=aaa.c \
bb.c \
include $(BUILD_STATIC_LIBRARY)


2. xxxxx/jni/lib2/Android.mk


LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)

LOCAL_MODULE    :=lib2

LOCAL_SRC_FILES :=asdf.c \
qwert.c \

include $(BUILD_STATIC_LIBRARY)




3. /jni/Android.mk



MY_JNI_FOLDER := $(call my-dir)
include $(MY_JNI_FOLDER)/lib1/Android.mk
include $(MY_JNI_FOLDER)/lib2/Android.mk




Now create another file Application.mk



APP_MODULES        := lib1 lib2 // Note that each module  specified here will perform a force build, which yields lib1.a and lib2.a
APP_OPTIM        := release
APP_ABI          := armeabi armeabi-v7a




Now, type build using ndk-build script

xxxxx@NHPC /cygdrive/c/android-ndk-r4b/samples/hello-jni/jni
$ ../../ndk-build

Monday, August 16, 2010

Phone, Battery, Usage Info/Statistics

As a Android mobile developer type *#*#4636#*#* on any Android deivce/ Emulator to read basic test applications such as

Phone Information,

Battery Inforamtion

Battery History,

Usage statistics

Friday, August 13, 2010

Recording with Android MediaRecorder API

MediaRecorder API, records in 3 file formats

1. 3gpp

2.AMR

3. Mp4

All there formats uses AMR encoder, code snippet given below recods for any audio source(as) such as:

MediaRecorder.AudioSource.DEFAULT,  MediaRecorder.AudioSource.VOICE_DOWNLINK,

MediaRecorder.AudioSource.VOICE_UPLINK, MediaRecorder.AudioSource.VOICE_CALL



mr = new MediaRecorder();
mr.setAudioSource(as); // as  = Audio Source
mr.setOutputFormat(ff); // ff = FileFormat
mr.setAudioEncoder(MediaRecorder.AudioEncoder.AMR_NB);
mr.setOutputFile(RECORDING_FILE); // filepath of the recording file
mr.prepare();
mr.start();




Note that, this API is compatible only with Android DONUT, does'nt work with Eclair and Froyo.

Tested and Verfied on LG GT 540 and guess to work with all devices based on this processor.















Microprocessor,-Chipset LG GT540 SWIFT (Optimus)


CPU:Clock:600 MHz
CPU: Qualcomm MSM7227
Browse devices based on this microprocessor

Getting the latest and right code


Android website has every detail on how to grab the latest source code, this article is just considered to get the right source code right platform.

After you sync the Android repos, you’ll see output describing the available branches and tags something like this:
 * [new branch]      cupcake    -> korg/cupcake
 * [new branch]      cupcake-release -> korg/cupcake-release
 * [new branch]      donut      -> korg/donut
 * [new branch]      donut-release -> korg/donut-release
 * [new branch]      eclair     -> korg/eclair
 * [new branch]      master     -> korg/master
 * [new branch]      release-1.0 -> korg/release-1.0
 * [new tag]         android-1.0 -> android-1.0
 * [new tag]         android-1.5 -> android-1.5
 * [new tag]         android-1.5r2 -> android-1.5r2
 * [new tag]         android-1.5r3 -> android-1.5r3
 * [new tag]         android-1.5r4 -> android-1.5r4
 * [new tag]         android-1.6_r1 -> android-1.6_r1
 * [new tag]         android-1.6_r1.1 -> android-1.6_r1.1
 * [new tag]         android-1.6_r1.2 -> android-1.6_r1.2

Some time contains other random stuff  and mostly confusing for newbies.

use of the following commands with repo for specific platform souce code.

Repo takes the -b option to specify a branch however, and the cupcake / donut / eclair branches are universal, so those are what I used to make the source archives linked in this article, e.g.:
repo init -u git://android.git.kernel.org/platform/manifest.git -b cupcake
repo sync


Make sure the Git port is open, the port is 9418 otherwise, timed out errors persists

Android build errors fix under Ubuntu 10.04

I'm not going to tale down on how to download and set up android, this article is mainly intended to fix Android build errors while compiling on Ubuntu 10.4

Below are the issue which I personally encountered while building Android sources.

1. bison not found

Install only bison via synaptic package manager

2.  Java version miss match
sudo apt-get remove sun-java6-jre sun-java6-jdk sun-java6-plugin

or
sudo apt-get autoremove sun-java6-jre sun-java6-jdk sun-java6-plugin


To Install java5
sudo apt-get install sun-java5-jre sun-java5-jdk sun-java5-plugin

To check which version of java is enabled
java -version

To change manually the java version



sudo update-alternatives --config java




then choose accordiingly

3. Error: zlib.h no such file or directory
error while compiling android sources with zlib.h not found

cgi.c:22:18: error: zlib.h: No such file or directory
Try this to get zlib.hGenerated: (out/target/product/generic/android-info.txt)
Target system fs image: out/target/product/generic/obj/PACKAGING/systemimage_unopt_intermediates/system.img
Install system fs image: out/target/product/generic/system.img
Target ram disk: out/target/product/generic/ramdisk.img
Target userdata fs image: out/target/product/generic/userdata.img
Installed file list: out/target/product/generic/installed-files.txt

$ sudo apt-get install zlib1g-dev

After that, you might need libncurse

$ sudo apt-get install libncurses5-dev

4: Flex command not found
Flex not found
Try installing flex through synaptic manager
or

sudo apt-get install flex

5. X11/Xlib.h: No such file or directory

Try installing libx11-dev from synaptic package manager

6. sh: gperf: not found

Try installing gperf from synaptic package manager

Finally, generated output files after successul Froyo Build

Generated: (out/target/product/generic/android-info.txt)
Target system fs image: out/target/product/generic/obj/PACKAGING/systemimage_unopt_intermediates/system.img
Install system fs image: out/target/product/generic/system.img
Target ram disk: out/target/product/generic/ramdisk.img
Target userdata fs image: out/target/product/generic/userdata.img
Installed file list: out/target/product/generic/installed-files.txt

Now how to Install self built Android images on Emulator


4. Backup the folder <android_sdk_folder>/platforms/android-8/images (android_sdk_folder is the Android SDK installation folder)

5. Replace the files ramdisk.img, system.img and userdata.img in <android_sdk_folder>/platforms/android-8/images with the files built from above steps.

6. Start the emulator and wait.

That’s it Now Enjoy Phone Emulator with Froyo update.

Monday, August 9, 2010

Using Safe Mode and Hard Reset on LG GT540

Using Safe Mode

Turn off you phone and reboot. While your phone is powering  back on , press and hold the Home key during Android log is displayed. your phone will bott all the way to the main screen  and display "safe mode " in lower left corner.

**For Google Nexus One: Restart phone and press 'Track Ball' Button for about 4 sec when Cross Mark icon is displayed.

Reboot phone for normal operations.

Using Hard Reset(factory reset)

If it in any case to restore to the original condition, use hard reset to initialise the target.

When your phone turns on and the lock screen displays, press and hold  the volume up+home key+Search keys all at the same time for about 5 sec. when the pop up screen is shown , choose OK  to reset the phone.

Note** All data and applications on the target(phone) will be erased and cannot be reversed.

How to root Android based LG GT540

For the GT540, LG introduced an additional level of security in the engineering application. It didn't really work out so well.

To enable Superuser access (root) on your GT540: - Turn on the device and click the icon to open the phone dialler - Enter the code '3845#*540#' - Select the option 'Module Test', then 'Stability Test' then 'Enable Root Permission' - You will now be prompted for a password - enter :SWIFT::GT540: - A toast message will briefly appear saying 'OK' - your root access is now enabled! - Reboot your device, and now when you connect via ADB, you'll see you have a root prompt (#).

Thursday, August 5, 2010

How to browse/attach android source code in Eclipse

android sources for acitivity class

Many Android developers spend more time in browsing Android sources ONLINE, But the following note is how to browse android source code offline with eclipse. below steps are confirmed to work on Win7 and Ubuntu 10.04. drop me a note if you have any issue(s).

steps:

1. create folder named "sources" in android_sdk  i,e in my case

xxx/android-sdk-linux_86/platforms/android-8/sources

2. The public SDK source is found in android_src/frameworks/base/core/java.
Under that folder you’ll find an 'android' directory, which should be copied (or symlinked) over to the sources directory in your SDK installation.
i:e /home/br/bin/U/android-sdk-linux_86/platforms/android-8/sources/android

3.Now extract all the sources of android into folder 'sources'

/home/xx/bin/U/android-sdk-linux_86/platforms/android-8/sources/android** copied from path "androd_src/frameworks/base/core/java"
/home/xx/bin/U/android-sdk-linux_86/platforms/android-8/sources/bionic
/home/xx/bin/U/android-sdk-linux_86/platforms/android-8/sources/bootable
/home/xx/bin/U/android-sdk-linux_86/platforms/android-8/sources/build
/home/br/bin/U/android-sdk-linux_86/platforms/android-8/sources/cts
/home/br/bin/U/android-sdk-linux_86/platforms/android-8/sources/dalvik
/home/xx/bin/U/android-sdk-linux_86/platforms/android-8/sources/development
/home/xx/bin/U/android-sdk-linux_86/platforms/android-8/sources/device
/home/xx/bin/U/android-sdk-linux_86/platforms/android-8/sources/external
/home/xx/bin/U/android-sdk-linux_86/platforms/android-8/sources/frameworks
/home/xx/bin/U/android-sdk-linux_86/platforms/android-8/sources/hardware
/home/xx/bin/U/android-sdk-linux_86/platforms/android-8/sources/libcore
/home/xx/bin/U/android-sdk-linux_86/platforms/android-8/sources/ndk
/home/xx/bin/U/android-sdk-linux_86/platforms/android-8/sources/packages
/home/xx/bin/U/android-sdk-linux_86/platforms/android-8/sources/prebuilt
/home/xx/bin/U/android-sdk-linux_86/platforms/android-8/sources/sdk
/home/xx/bin/U/android-sdk-linux_86/platforms/android-8/sources/system
/home/xx/bin/U/android-sdk-linux_86/platforms/android-8/sources/Makefile

4. click refresh on projct explorer or restart eclipse,and to test just open any android class file, jus open activity.class and there you go...

Next steps will follow on how to build  User defined shared (.so)and static libraries using Android NDK and SDK