Aapo Rantalainen's blog

Experiences with Information Technology and Open source

Playing with Android

Posted by Aapo Rantalainen on April 6, 2010

I was in Codecamp playing with Android and this is story of my experience with it.

Android is operating system (uses Linux kernel) for mobile phones by Google.


  • It is fully open source.


  • Not all kernel modifications are in upstream.
  • It is not using GNU (there are not all ‘standard’ libraries of GNU/Linux system)

My goal – native C

For Java developers Android is good choice. There are ready plugins for Eclipse to produce Android applications. But at this time I was not interested in Java development. I had one goal: Compile some c-applications natively to Android.

If you want mix java and C-code check NDK.



I downloaded Android SDK and AVD Manager for x86-Linux. It contains graphical UI to create, manage and start virtual phones. It has also manager to download all needed file-images as well. I tested Android 2.0, 2.0.1 and 2.1 (API levels 5,6 and 7). Screen can be switched between portrait and landscape with ctrl+F11.

SDK contains also handy tool called adb, which stands AndroidDebugBridge. It can be used to push files to virtual device or shell access.


There are many howtos how to build Android crosscompile environment. There are some know issues:

  • No java5 in modern distribution (I used 9.04 repositories on my 9.10 ubuntu)
  • gcc-4.3 needed but gcc-4.4 installed (I have both installed and moved symlinks)
  • Errors: java.util.zip.ZipException: duplicate entry: hyts_Foo.c (I just deleted all dublicate files)

I suggest to use droid-wrapper (or some other script) to make things easier. Just install it with make install, and use it with:

DROID_TARGET=generic DROID_ROOT=/home/rantalai/mydroid/ droid-gcc main.c


export DROID_TARGET=generic
export DROID_ROOT=/home/rantalai/mydroid/

and then



I got hello world compiled and pushed to virtual device (emulator must be first running).

droid-gcc hello.c
adb push a.out /data/hello

First parameter is filename, second is target filename with path. Data-folder is writable.


In virtual phone there is ‘Dev Tools’ -> ‘Terminal Emulator’. Then I typed /data/hello

It is very limited shell and there are no permissions to ls data.

I found and tested precompiled Bash 3.2.

wget http://pub.mzet.net/bash
chmod a+x bash
adb push bash /data/bash


There are no X running, so I needed some other way to make graphical application. There were GLES examples in android-git but they didn’t work very well, screen flickered etc.

I read that SDL 1.2.13 can be compiled for Android. There are workers with newer (1.2.14) SDL. And even android port. But 1.2.13 was enough for me.

I got it compiled and tested with testbitmap.c (I first changed resolution to 320×240 in line 99)

droid-gcc testbitmap.c -I../include -L../ -lSDL
adb push a.out /data/test
adb shell /data/test

For some reason I can’t start this SDL-test on phones terminal (“No available video device”).

Then I found that SDL and OpenGL can be mixed together with tinysdgl and there was instructions for android (there were some missing parts).

I got it compiled and now I can compile examples. First I tuned resolutions to 320X240, then I copied mydroid/prebuilt/linux-x86/toolchain/arm-eabi-4.3.1/lib/gcc/arm-eabi/4.3.1/libgcc.a to working directory (there is some issue).

droid-gcc -static -I../include/ -I../../../SDL-1.2.13/include/ -c gears.c
droid-ld -static gears.o -o gears -L../lib -lTinySDGL -L../../../SDL-1.2.13  -lSDL libgcc.a

On the video, when I move camera and there are lagging, it is because emulator doesn’t recognize pressed mouse button, but only clicking. It has about 16fps all the time.

droid-gcc -static -I../include/ -I../../../SDL-1.2.13/include/ -c triangle.c
droid-ld -static triangle.o -o triangle -L../lib -lTinySDGL -lTinyGLU -L../../../SDL-1.2.13  -lSDL libgcc.a

And lastly there are my library for plotting mathematical functions, called aaplot.

And code for aaplot (GPLv3).

Real device

And then I got Real Android device, Motorola Milestone (Motodroid), in my hand. I thought that everything working on emulator will work on real device. First I had problems with connecting it to my computer (until I update phone’s firmware and then it worked). Then I tried to push my binaries to phone with adb and it sayd:  “you can not root on a production build of android”. I was very disappointed of Motorola. I think best thing of Android is that it is not iPhone. User should has access to own device without jailbreaking.

Read more about discussion of root access.

Read more about jailbreaking (rooting) of Milestone. I didn’t get this working, maybe it is because I had too new firmware (because of that USB connection bug). If you got aaplot running on real android device, drop me a post.

One Response to “Playing with Android”

  1. androidz said

    Cool Android emulator… Thanks for the Info…

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: