I am trying to embed the Knopflerfish framework into an android application to load and unload bundles dynamically. I followed this tutorial
The first step I did is
At the comment // add any framework properties to fwprops
,
I only had to add the Framework launching property specifying the persistent storage directory used by the framework. Since it is Android, the default value for the storage directory doesn't seem to work. Instead, I should specify the directory under sdcard
. Hence, I added this line:
fwprops.put("org.osgi.framework.storage", "sdcard/fwdir");
Below is my updated code:
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Map<String, String> fwprops = new Hashtable<String, String>(); //CHANGED
// add any framework properties to fwprops
fwprops.put("org.osgi.framework.storage", "sdcard/fwdir");
FrameworkFactory ff = new FrameworkFactoryImpl();
mFramework = ff.newFramework(fwprops);
try {
mFramework.init(); //THIS WORKS NOW :P :P
} catch (BundleException be) {
// framework initialization failed
Log.d(TAG, be.getStackTrace().toString());
}
}
Thanks to these two links: http://www.osgi.org/javadoc/r4v43/core/org/osgi/framework/Constants.html#FRAMEWORK_STORAGE http://www.knopflerfish.org/releases/current/docs/bundledoc/index.html?docpage=framework/index.html