I have an OSGI Bundle which is an eclipse plugin project. In this bundle, I am trying to use the android API to print a message on LogCat. The way I was led in these two questions 1 , 2 to achieve that is to get a real implementation of Android API and to prepare it as separate bundle which exports android.util
so that my bundle import android.util
and use it. Okay, I did all these steps. I used this android source code, and Below is my bundle's Activator class:
package bundle_androidapi;
import org.osgi.framework.BundleActivator;
import org.osgi.framework.BundleContext;
import android.util.Log;
public class Activator implements BundleActivator {
private static BundleContext context;
static BundleContext getContext() {
return context;
}
/*
* (non-Javadoc)
* @see org.osgi.framework.BundleActivator#start(org.osgi.framework.BundleContext)
*/
public void start(BundleContext bundleContext) throws Exception {
Activator.context = bundleContext;
System.out.println("Hello World. I am the OSGI_Android_Bundle!");
Log.d("Zaid Log", "Hello World. I am the OSGI_Android_Bundle!!");
}
/*
* (non-Javadoc)
* @see org.osgi.framework.BundleActivator#stop(org.osgi.framework.BundleContext)
*/
public void stop(BundleContext bundleContext) throws Exception {
Activator.context = null;
System.out.println("Goodbye World. I am the OSGI_Android_Bundle!");
Log.d("Zaid Log", "Goodbye World. I am the OSGI_Android_Bundle!!");
}
}
At the line that uses Log.d(), I get the following errors:
!ENTRY Bundle_AndroidAPI 4 0 2013-08-14 15:10:53.638
!MESSAGE FrameworkEvent ERROR
!STACK 0
org.osgi.framework.BundleException: Exception in bundle_androidapi.Activator.start() of bundle Bundle_AndroidAPI.
at org.eclipse.osgi.framework.internal.core.BundleContextImpl.startActivator(BundleContextImpl.java:734)
at org.eclipse.osgi.framework.internal.core.BundleContextImpl.start(BundleContextImpl.java:683)
at org.eclipse.osgi.framework.internal.core.BundleHost.startWorker(BundleHost.java:381)
at org.eclipse.osgi.framework.internal.core.AbstractBundle.resume(AbstractBundle.java:390)
at org.eclipse.osgi.framework.internal.core.Framework.resumeBundle(Framework.java:1177)
at org.eclipse.osgi.framework.internal.core.StartLevelManager.resumeBundles(StartLevelManager.java:559)
at org.eclipse.osgi.framework.internal.core.StartLevelManager.resumeBundles(StartLevelManager.java:544)
at org.eclipse.osgi.framework.internal.core.StartLevelManager.incFWSL(StartLevelManager.java:457)
at org.eclipse.osgi.framework.internal.core.StartLevelManager.doSetStartLevel(StartLevelManager.java:243)
at org.eclipse.osgi.framework.internal.core.StartLevelManager.dispatchEvent(StartLevelManager.java:438)
at org.eclipse.osgi.framework.internal.core.StartLevelManager.dispatchEvent(StartLevelManager.java:1)
at org.eclipse.osgi.framework.eventmgr.EventManager.dispatchEvent(EventManager.java:230)
at org.eclipse.osgi.framework.eventmgr.EventManager$EventThread.run(EventManager.java:340)
Caused by: java.lang.UnsatisfiedLinkError: android.util.Log.println_native(IILjava/lang/String;Ljava/lang/String;)I
at android.util.Log.println_native(Native Method)
at android.util.Log.d(Log.java:138)
at bundle_androidapi.Activator.start(Activator.java:27)
at org.eclipse.osgi.framework.internal.core.BundleContextImpl$1.run(BundleContextImpl.java:711)
at java.security.AccessController.doPrivileged(Native Method)
at org.eclipse.osgi.framework.internal.core.BundleContextImpl.startActivator(BundleContextImpl.java:702)
... 12 more
Root exception:
java.lang.UnsatisfiedLinkError: android.util.Log.println_native(IILjava/lang/String;Ljava/lang/String;)I
at android.util.Log.println_native(Native Method)
at android.util.Log.d(Log.java:138)
at bundle_androidapi.Activator.start(Activator.java:27)
at org.eclipse.osgi.framework.internal.core.BundleContextImpl$1.run(BundleContextImpl.java:711)
at java.security.AccessController.doPrivileged(Native Method)
at org.eclipse.osgi.framework.internal.core.BundleContextImpl.startActivator(BundleContextImpl.java:702)
at org.eclipse.osgi.framework.internal.core.BundleContextImpl.start(BundleContextImpl.java:683)
at org.eclipse.osgi.framework.internal.core.BundleHost.startWorker(BundleHost.java:381)
at org.eclipse.osgi.framework.internal.core.AbstractBundle.resume(AbstractBundle.java:390)
at org.eclipse.osgi.framework.internal.core.Framework.resumeBundle(Framework.java:1177)
at org.eclipse.osgi.framework.internal.core.StartLevelManager.resumeBundles(StartLevelManager.java:559)
at org.eclipse.osgi.framework.internal.core.StartLevelManager.resumeBundles(StartLevelManager.java:544)
at org.eclipse.osgi.framework.internal.core.StartLevelManager.incFWSL(StartLevelManager.java:457)
at org.eclipse.osgi.framework.internal.core.StartLevelManager.doSetStartLevel(StartLevelManager.java:243)
at org.eclipse.osgi.framework.internal.core.StartLevelManager.dispatchEvent(StartLevelManager.java:438)
at org.eclipse.osgi.framework.internal.core.StartLevelManager.dispatchEvent(StartLevelManager.java:1)
at org.eclipse.osgi.framework.eventmgr.EventManager.dispatchEvent(EventManager.java:230)
at org.eclipse.osgi.framework.eventmgr.EventManager$EventThread.run(EventManager.java:340)
Can someone tell me how can I get rid of the above errors.
Below is my MANIFEST.MF:
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: Bundle_AndroidAPI
Bundle-SymbolicName: Bundle_AndroidAPI
Bundle-Version: 1.0.0.qualifier
Bundle-Activator: bundle_androidapi.Activator
Import-Package: org.osgi.framework;version="1.3.0", android.util
Bundle-RequiredExecutionEnvironment: JavaSE-1.6
Note: I am trying since 1 week to get my bundle to use andorid API, but I keep failing. My target is not just a Log message to be printed, but to have my bundle using Android API successfully, so am I following the right way? Is there a reason, why I keep failing and getting these errors? Thanks.