Embedding Knopflerfish in Android doesn't work

前端 未结 1 1444
花落未央
花落未央 2021-01-07 02:42

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

相关标签:
1条回答
  • 2021-01-07 03:00

    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

    0 讨论(0)
提交回复
热议问题