Take the 2-minute tour ×

I'm actually working on OSGi on Android, and I'm close to reach my goal, but there's one little problem.

The framework (Apache Felix) is running successfully. The problem comes from Bundles that want to get Context of the Application. I just can't try to use them, because at runtime, I've got a beautiful "Could not find classe Android.content.Context", refrenced from [...]. (And then come a NoClassDefFoundError when trying to get the ServiceReference)

I linked the Android.jar to the Bundle, but it doesn't seems to be enough (even if compilation is ok). Maybe it's the way I'm creating the bundle that's wrong, I juste export it as a .jar when finished.

So if you've got some tips about how to solve this problem, they're welcome ;)

Thanks !

share|improve this question
Is Android.content.Context part of the Android API? It sounds like this needs to be exposed as an export of the system bundle. You could do this by adding Android.content to the org.osgi.framework.system.packages.extra property. –  Neil Bartlett Mar 4 '11 at 5:52
Well, unfortunately, I already tried that, doing configMap.put(Constants.FRAMEWORK_SYSTEMPACKAGES_EXTRA, "android.content"); Then, in the Activator, I'm registering the current Context like that :this.m_context.registerService(Context.class.getName(), appContext, null); Finally, I'm trying to get the corresponding ServiceReference in this way : ServiceReference ref = context.getServiceReference(Context.class.getName()); but it throws an "NoClassDefFoundError" at runtime for this line. –  Quentin Mar 4 '11 at 11:40

1 Answer 1

Ok, I'm finally done with it. I am a fool, really.

In the Manifest.mf, section "Import-Package", don't forgot to add android.content

It now works perfectly ;)

share|improve this answer

Your Answer


