Thursday, July 9, 2009

How to build OBEX in Android

First of all, they are all for Android Dev Phone. You need to have root permission in Android devices. My working machine is Ubuntu 9.04 and I use Android tool chain to compile these applications.

1. Prepare working environment:
Check Android official website and they provide a user guide. It tells me how to download Android source code and how to compile it.

It took me few hours to set up environment, download code, and make the whole building system. Like my friend said, all OTAKU in Taiwan have android source code in their machine.

If you can run Android emulator from your compiled result, it should mean DONE. :)

2. Build it for DREAM:
The Android emulator in item one doesn't support bluetooth and I cannot play OBEX in it. I choose to play it with my Android Dev Phone. Then I modified my build system and changed some configuration files. Check another document from Android, it tells me how to change my building environment. Also, if you'd like to use the official system images, you can download them from HTC.

3. Download OBEX source codes from android-obex:

a. build openobex

> cd $MYDROID (change folder to mydroid folder)
> cd external (change folder to external directory, it's for native code)
> git clone git://gitorious.org/android-obex/openobex.git (it would download code to openobex folder)
> cd openobex
> . ../../build/envsetup.sh (run android env setup script)
> mm (it would run Android makefile to compile sources)

After running above commands, it would generate related libraries and binary files in android 'out' directory.

one static library: libopenobex (out/target/product/dream/obj/STATIC_LIBRARIES/libopenobex_intermediates/libopenobex.a)
one binary file: obex_test (out/target/product/dream/system/bin/obex_test)

use USB cable to upload binary file to Android Dev Phone.

> adb shell
> mount -o remount,rw -t yaffs2 /dev/block/mtdblock3 /system (add WRITE permission in system dir)
> adb push $MYDROID/out/target/product/dream/system/bin/obex_test /system/bin

b. build obexpushd

> cd $MYDROID (change folder to mydroid folder)
> cd external (change folder to external directory, it's for native code)
> git clone git clone git://gitorious.org/android-obex/obexpushd.git (it would download code to obexpushd folder)
> cd obexpushd/src
> . ../../build/envsetup.sh (run android env setup script)
> mm (it would run Android makefile to compile sources)

After running above commands, it would generate one binary files in android 'out' directory. The same as openobex, you can use adb push to upload binary file to Android Dev Phone. BTW, you should compile openobex before obexpushd, coz obexpushd need to use openobex libraries.

one binary file: obexpushd (out/target/product/dream/system/xbin/obexpushd)

4. Verify OBEX functions between Ubuntu machine and Android Dev Phone. Check the previous article about it.

PS. if you are not interested in source codes, you can download the binary files from here.

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.