| Update A new community is launched around running Apache Felix an Android: EZdroid community |
Description
As an example of how to create a dynamic, OSGi based application for Android, we have ported the "paint program" from the Apache Felix website.
Design
We chose the service based example as our basis. The first thing we had to do was create an Android application that contains Felix. Within that application we defined an Activity that is registered within Android and forms the starting point for any bundle that wants to display a user interface. A ViewFactory interface, containing a create() method is used, applying the whiteboard pattern, to contribute a new view. Our example currently supports only one such view at a time, but it would not be too hard to show different views in tabs, create a desktop with icons for each view, or even create some OpenGL based coverflow like front end.
To allow easy deployment, we included a copy of the freshly contributed FileInstall. That way we can simply copy bundles onto the device to deploy them, creating a very simple management agent.
Next step was the creation of a host bundle that contributes a view with a toolbar at the top and a canvas below. Because Android uses its own graphics library, we could not directly use the Swing and Java2D based API present in the original sample, but we used the same concepts.
Finally we created bundles that contributed individual shapes to the application: circle, triangle and square. The diagram below shows this design:

Usage
To be able to compile and run these examples, you need at least the M5 release of the Android SDK as well as the Eclipse plugin.
You can checkout the following Eclipse projects:
- https://opensource.luminis.net/svn/OSGIANDROID/trunk/net.luminis.android.apachecon.felix/
- https://opensource.luminis.net/svn/OSGIANDROID/trunk/net.luminis.android.servicebased.host/
- https://opensource.luminis.net/svn/OSGIANDROID/trunk/net.luminis.android.servicebased.circle/
- https://opensource.luminis.net/svn/OSGIANDROID/trunk/net.luminis.android.servicebased.square/
- https://opensource.luminis.net/svn/OSGIANDROID/trunk/net.luminis.android.servicebased.triangle/
The projects use Ant build files to package bundles and deploy them to the right directory on the emulator. You need to modify your path to "android.home" to match the location where you installed the SDK and the emulator should be running already to deploy bundles.
Downloads
- NL-JUG J-Spring 2008 presentation we gave on creating dynamic, OSGi based applications on Google Android using Apache Felix at the J-Spring 2008.
Authors
- [~karlp]
- Marcel Offermans

Comments (5)
May 14, 2009
Anonymous says:
the svn checkout doesn't work. can you please fix that? Error: $ svn co https:...the svn checkout doesn't work. can you please fix that?
Error:
$ svn co https://opensource.luminis.net/subversion/oss/projects/osgi-android/trunk/net.luminis.android.felix/
Error validating server certificate for 'https://opensource.luminis.net:443':
fingerprint to validate the certificate manually!
Certificate information:
(R)eject, accept (t)emporarily or accept (p)ermanently? t
svn: PROPFIND request failed on '/subversion/oss/projects/osgi-android/trunk/net.luminis.android.felix'
svn: PROPFIND of '/subversion/oss/projects/osgi-android/trunk/net.luminis.android.felix': 501 Method PROPFIND is not defined in RFC 2068 and is not supported by the Servlet API (https://opensource.luminis.net)
May 18, 2009
Arjan Schaaf says:
Sorry for that, the URL's were incorrect. The right path is: https://opensource....Sorry for that, the URL's were incorrect. The right path is: https://opensource.luminis.net/svn/OSGIANDROID/trunk/net.luminis.android.apachecon.felix/
Sep 14, 2009
Anonymous says:
hello, I've downloaded the projects from the repositories and some projects lik...hello,
I've downloaded the projects from the repositories and some projects like net.luminis.android.apachecon.felix, net.luminis.android.servicebased.circle, net.luminis.android.servicebase.triangle works fine and there are no problem with them. The projects
net.luminis.android.servicebased.square and net.luminis.android.servicebased.host show some errors in the manifest.mf saying "no available bunble export package" and in the net.luminis.android.servicebased.host there is an error in the activator file "the import android.view.UIThreatUtilities" cannot be resolved.
I would appreciate if you can help me with those errors please.
Best regards!
my email is: ryoussefi(
at)gmail.comSep 16, 2009
Marcel Offermans says:
Those errors can be safely ignored. Eclipse has problems understanding projects ...Those errors can be safely ignored. Eclipse has problems understanding projects that are both OSGi bundles and Android projects. I'm sure there is a solution for that, but I did not invest the time to find it. It works right now though.
May 10
Anonymous says:
I can't get the program to work. Neither at the emulator (in every version) nor ...I can't get the program to work.
Neither at the emulator (in every version) nor at my Android 2.1 Phone.
After starting the application all I will get is a black screen, no mather how long a wait.
I tried also to manually dex the felix jar's, but the dalvikvm couldn't find the Main-Class.
Could you give any support or are there any known problems with never releases of the Android-JDK?
Add Comment