ProSyst publishes OSGi for Android
Today ProSyst released the beta version of mBedded Server (mBS) for Android. mBS is the leading OSGi implementation in the embedded market. The beta release of the Android version is available from here. This release is under ProSyst Non-Commercial License, which permits free use for non-commercial trials.
Why to use OSGi on top of Android?
OSGi and Android are both component platforms. However, due to the differences discussed in an earlier post about Android, there are significant benefits in using OSGi on top of Android:
- Lack of class-sharing: Android doesn’t support the class sharing between application packages, which leads to class duplication between components of a modularly deployable application. Such class duplication puts high burden on platform maintenance as well if there are shared components.
- Fine-grained components: in Android, component communication involves interprocess communication which leads to coarse-grained components with high abstraction-level interfaces. The efficient communication between OSGi components - i.e. direct method calls - permits a much finer grained decomposition. The fine-grained component model enables plugin architectures like in Eclipse eRCP.
- Device Management: Remote manageability is an essential feature both for enterprises and mobile operator. Android currently doesn’t include this feature, but OSGi offers an out of the box solution for this are.
Release Content and Requirements
Content of the release:
- mbs.apk - mBS for Android
- mconsole-proff-6.1.41-19-12-2007.zip - ProSyst mConsole remote management tool
- demo.zip - Bundles demonstrating the use of OSGi services on top of Android
- readme.htm - Detailed installation instruction for the release and the demos
- ProSyst Non-Commercial license.txt
mBS for Android
The mbs.apk package contains the mBS distribution as an Android application package. It can be directly deployed to Android using the adb tool. The product can then be found under the All desktop item. 
This mBS distribution contains the full OSGi R4 framework implementation and the following services:
The mBS port works with Android M5 or later as it depends on some bugfixes introduced in the M5 release.
mConsole
The mconsole-proff-6.1.41-19-12-2007.zip contains ProSyst mConsole, a remote management console that allows the management of OSGi framework. This package can be installed to a PC and it can be used to remotely manage the OSGi framework running on Android. This version of mConsole uses the ProSyst Management Protocol for the management but other management protocols are supported as well. Using the management console allows:
- Installing/updating a bundle to the framework
- Uninstalling bundles
- Starting/stopping bundles
mConsole runs on Windows-based PCs.
Porting Experience
Porting Java applications to Android, if it doesn’t involve the porting of UI should be easy. However, during the technical work, ProSyst team had to face some challenges due to some bugs in Android and the lack of documentation for the Dalvik Virtual Machine. The major issues are described here to help the work of other porting projects:
Stack Size
By default the stack size of the Dalvik VM is set to 1 KB. Which was a bit few when starting mBS with a large number of bundles. The stack size can be set using the -Xss command line argument. For example -Xss65536 sets the stack size to 64K. Unfortunately, it’s not known how this argument can be specified for a regular Android application. As a workaround for this issue, mBS was modified to explicitly set the stack size when the corresponding Thread objects are created.
DEX converter bugs
There are some bugs in the dx tool provided in Android. ProSyst reported these bugs to Google, but it’s good to be aware of these limitations until the problems are fixed.
The dx tool fails to generate code for the following try-catch-finally structure:
try {
// do something but do not return anything.
// If you have "return object" here the
// construction is OK.
} catch (Throwable th) {
// log the error
} finally {
// free the resources
// The DEX file generator fails to parse
// this section and starts eating memory
// and doing nothing.
}
Another failing construct is when Object[] is used to refer to different types of arrays, like in the code snippet below:
Object[] data = null;
if (condition1) {
data = new String[10];
} else if (condition2) {
data = new MyObject[10];
}
Future Plans
ProSyst is working on additional demos and tools that help to leverage this technology. This release was created as a proof of concept to demonstrate the feasibility of using mBS on Android. However, ProSyst can productize this version if there is a significant interest in using this technology.
Article by Gábor Pécsy


March 21st, 2008 at 11:02 am
Gábor. Thank you!
I’ve been looking at OSGi in relation to our services, and in doing my research came across the news of Sprint requiring OSGi for their WiMax implementation.
My first thoughts were “I hope Android supports OSGi”… and it does, thanks to you.
One other thing: you said “the major issues are described here to help the work of other porting projects”. There is something beautiful about that, about a world where people volunteer their efforts to help others. If only our national governments could be as generous to each other as the software community is becoming.
April 29th, 2008 at 12:50 pm
I think I don’t see very well what are the differences between Felix for Android and mBS. Can you help me to understand this point ?
Thx
May 2nd, 2008 at 6:43 am
There are two major differences, I think:
- the Felix port could be started from a console connection, so it’s not really applicable for end-user applications. Basically, iy wouldn’t be usable in its current form on a real Android device. mBS runs as an application, you can start it as any other Android application.
- we ported a lot more services, including management protocol adapters, which allow remote management of the platform. As you can see with mConsole you can remotely deploy bundles, start and stop them etc. Which is a lot more than you can currently do with Android “native” applications as well.
May 22nd, 2008 at 10:32 pm
@cr0vax I think the main differences you will find come down to quality. ProSyst’s implementation of OSGi is based on Equinox (Eclipse!) and is what I call “commercially complete” containing stable and well tested features with additional features such as their very good remote console. Felix, on the other hand, is buggy in comparison (in my experience) and like a lot of “free” open source projects appears to be suffering from “too many chefs” and a lack of direction/leadership - though that is just my personal perception.
May 29th, 2008 at 3:19 pm
@Chris
Probably you meant mBS Professional Edition instead of Equinox (edition of ProSyst mBedded Server). Indeed the OSGi port for Android is based on the ProSyst’s mBS Professional Edition, which is more mature and better tuned than the mBS Equinox Edition.