在开始嵌入到Android的Knopflerfish一个Bundle不起作用 [英] Starting a Bundle on Knopflerfish embedded into Android doesn't work

查看:822
本文介绍了在开始嵌入到Android的Knopflerfish一个Bundle不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我嵌入Knopflerfish框架变成一个Android应用程序启动和停止动态捆绑。

我跟着本教程中,已下载framework.jar弗罗姆链接,并将其添加到我的类路径在我的Eclipse项目

此外,下面是活动类,它启动的框架和启动一个包:

 包com.example.knopflerfish_android;进口的java.io.File;
进口java.io.IOException异常;
进口的java.io.InputStream;
进口java.util.Dictionary中;
进口的java.util.Hashtable;
进口的java.util.Map;
进口android.os.Bundle;
进口android.app.Activity;
进口android.util.Log;
进口android.view.Menu;
进口android.widget.Toast;进口org.knopflerfish.framework.FrameworkFactoryImpl;
进口org.osgi.framework.BundleException;
进口org.osgi.framework.ServiceReference;
进口org.osgi.framework.launch.Framework;
进口org.osgi.framework.launch.FrameworkFactory;
进口org.osgi.service.startlevel.StartLevel;
公共类MainActivity延伸活动{私有静态最后弦乐TAG =扎伊德日志;
私人框架mFramework;    @覆盖
    保护无效的onCreate(捆绑savedInstanceState){
        super.onCreate(savedInstanceState);
        的setContentView(R.layout.activity_main);
        的System.out.println(在这里!);        地图<字符串,字符串> fwprops =新的Hashtable<字符串,字符串>(); // CHANGED        //添加任何框架属性fwprops
        fwprops.put(org.osgi.framework.storage,SD卡/ FWDIR);        FrameworkFactory FF =新FrameworkFactoryImpl();
        mFramework = ff.newFramework(fwprops);        尝试{            mFramework.init(); // STUCK在这里!
        }赶上(BundleException定){
            //框架初始化失败            Log.d(TAG,be.getStackTrace()的toString());
            Log.d(TAG,初始化失败框架);
        }        setInitlevel(1);
        installBundle(Bundle_AndroidAPI_1.0.0.201308160327.jar);
        startBundle(Bundle_AndroidAPI_1.0.0.201308160327.jar);
        //安装/启动其他包...
        setStartLevel(10);        尝试{
            mFramework.start();
        }赶上(BundleException定){
            Log.e(TAG,be.toString());
            //框架启动失败
        }        Log.d(TAG,OSGi框架运行,状态:+ mFramework.getState());
      / * helloServiceReference = context.getServiceReference(HelloService.class.getName());
        HelloService的HelloService中=(HelloService中)context.getService(helloServiceReference);
        的System.out.println(helloService.sayHello()); * /
    }    @覆盖
    公共布尔onCreateOptionsMenu(菜单菜单){
        //充气菜单;如果是present这增加了项目操作栏。
        。getMenuInflater()膨胀(R.menu.main,菜单);
        返回true;
    }
    私人无效startBundle(捆好){
        Log.d(TAG,开始捆绑+包);
        InputStream的BS;
        尝试{
            BS = getAssets()开(包/+包)。
        }赶上(IOException异常五){
            Log.e(TAG,e.toString());
            返回;
        }        长投标= -1;
        为org.osgi.framework.Bundle [](BL)= mFramework.getBundleContext()getBundles()。
        的for(int i = 0; BL = NULL&放大器;!&安培; I< bl.length;我++){
            如果(bundle.equals(BL [I] .getLocation())){
                投标= BL [I] .getBundleId();
            }
        }        为org.osgi.framework.Bundle B = mFramework.getBundleContext()的getBundle(BID)。
        如果(二== NULL){
            Log.e(TAG,无法启动捆绑+包);            返回;
        }        尝试{
            b.start(org.osgi.framework.Bundle.START_ACTIVATION_POLICY);
            Log.d(TAG,捆绑式+ b.getSymbolicName()+/+ b.getBundleId()+/
                    + B +开始);
            Toast.makeText(getApplicationContext(),捆绑式+ b.getSymbolicName()+/+ b.getBundleId()+/
                    + B +开始,Toast.LENGTH_SHORT).show();
        }赶上(BundleException定){
            Log.e(TAG,be.toString());
        }        尝试{
            bs.close();
        }赶上(IOException异常五){
            Log.e(TAG,e.toString());
        }
    }    私人无效installBundle(捆好){
        Log.d(TAG,安装包+包);
        Toast.makeText(getApplicationContext(),安装包,Toast.LENGTH_SHORT).show();        InputStream的BS;
        尝试{
            BS = getAssets()开(包/+包)。
        }赶上(IOException异常五){
            Log.e(TAG,e.toString());
            返回;
        }        尝试{
            。mFramework.getBundleContext()installBundle(捆绑,BS);
            Log.d(TAG,捆绑式+捆绑+安装);
            Toast.makeText(getApplicationContext(),捆绑式+捆绑+已安装,Toast.LENGTH_SHORT).show();
        }赶上(BundleException定){
            Log.e(TAG,be.toString());
        }        尝试{
            bs.close();
        }赶上(IOException异常五){
            Log.e(TAG,e.toString());
        }
    }    私人无效setStartLevel(INT STARTLEVEL){
        服务引用SR = mFramework.getBundleContext()
            .getServiceReference(StartLevel.class.getName());
        如果(SR!= NULL){
            STARTLEVEL SS =
                (STARTLEVEL)mFramework.getBundleContext()的getService(SR)。
            ss.setStartLevel(STARTLEVEL);
            。mFramework.getBundleContext()ungetService(SR);
        }其他{
            Log.e(TAG,没有启动级别服务+ STARTLEVEL);
        }
    }    私人无效setInitlevel(INT级){
        服务引用SR = mFramework.getBundleContext()
            .getServiceReference(StartLevel.class.getName());
        如果(SR!= NULL){
            STARTLEVEL SS =
                (STARTLEVEL)mFramework.getBundleContext()的getService(SR)。
            ss.setInitialBundleStartLevel(水平);
            。mFramework.getBundleContext()ungetService(SR);
            Log.d(TAGinitlevel+等级+设置);
        }其他{
            Log.e(TAG,没有启动级别服务+级);
        }
    }
}

我在<一说href=\"http://stackoverflow.com/questions/18037496/embedding-knopflerfish-in-android-doesnt-work\">$p$pvious问题,根据@ldx在<一个href=\"http://stackoverflow.com/questions/8591976/how-can-an-android-activity-use-a-knopflerfish-osgi-bundle-installed-on-the-devi\">this后,我Knopflerfish提交了更好的Andr​​oid / Dalvik的支持补丁已经被合并,以便修补和重新编译KF不应该是必要再:

,所以我并没有添加任何假设我的code是足够的,因为它是现在。

当我运行Android应用程序,我没有得到任何错误,相反,我得到我的LogCat中说我束安装并启动了积极的信息。看我的日志如下(我忽略第一个2线):

  08-15 23:32:08.381:E /跟踪(22044):错误打开跟踪文件:没有这样的文件或目录(2)
08-15 23:32:08.381:E /跟踪(22044):错误打开跟踪文件:没有这样的文件或目录(2)
08-15 23:32:09.441:我/的System.out(22044):在这里!
08-15 23:32:10.320:D / dalvikvm(22044):GC_CONCURRENT释放172K,10%免费2695K / 2984K,暂停73ms + 85ms,总236ms
08-15 23:32:10.720:D / dalvikvm(22044):GC_CONCURRENT释放324K,14%免费2816K / 3260K,暂停73ms + 85ms,总214ms
08-15 23:32:10.762:D /扎伊德日志(22044):initlevel 1套
08-15 23:32:10.762:D /扎伊德日志(22044):安装捆绑Bundle_AndroidAPI_1.0.0.201308160327.jar
08-15 23:32:11.060:D /扎伊德日志(22044):软件包安装Bundle_AndroidAPI_1.0.0.201308160327.jar
08-15 23:32:11.080:D /扎伊德日志(22044):启动捆绑Bundle_AndroidAPI_1.0.0.201308160327.jar
08-15 23:32:11.090:D /扎伊德日志(22044):捆绑Bundle_AndroidAPI / 4 / BundleImpl [ID = 4]启动
08-15 23:32:11.140:D /扎伊德日志(22044):OSGi框架运行,状态:32
08-15 23:32:12.012:D / gralloc_goldfish(22044):无仿真模拟GPU检测。
08-15 23:32:52.941:I /编舞(22044):跳过47帧!该应用程序可能会做它的主线程的工作太多了。

不过,我的包并没有真正启动。在束的启动方法的消息就已经表明了在LogCat中,如果我的包才真正开始。下面是我的包开始的方法:

 公共无效启动(BundleContext的的BundleContext)抛出异常{
    Activator.context =的BundleContext;
    的System.out.println(世界您好我是OSGI_Android_Bundle!);
}

请注意,我的包被dexified,但是却又并不在我的应用程序启动。我去哪儿了?

更新1:我想我应该交换架构的起点同捆的开始。本教程的作者首先启动包,但我想改变这种状况,因为它是有道理的,首先启动的框架,所以我的更新code有以下几点:

  setInitlevel(1);
//安装/启动其他包...
setStartLevel(10);尝试{
    mFramework.start();
}赶上(BundleException定){
    Log.e(TAG,be.toString());
    //框架启动失败
}Log.d(TAG,OSGi框架运行,状态:+ mFramework.getState());
installBundle(束Test_1.0.0.201308160536.jar);
startBundle(束Test_1.0.0.201308160536.jar);

现在,日志不显示我,我的包作为前就开始,而是它告诉我,执行环境不支持。请参见下面的更新LogCat中:

 一月8日至16日:43:06.821:我/的System.out(22737):在这里!
一月八日至16日:43:08.080:D / dalvikvm(22737):GC_CONCURRENT释放191K,11%免费2656K / 2968K,暂停为35ms + 18毫秒,总155ms
一月八日至16日:43:09.010:D / dalvikvm(22737):GC_CONCURRENT释放276K,13%免费2806K / 3200K,暂停25ms的15ms的+,共有110毫秒
一月八日至16日:43:09.238:D /扎伊德日志(22737):initlevel 1套
一月八日至16日:43:09.300:D /扎伊德日志(22737):OSGi框架运行,状态:32
一月八日至16日:43:09.300:D /扎伊德日志(22737):安装捆绑包,Test_1.0.0.201308160536.jar
一月八日至16日:43:09.530:D /扎伊德日志(22737):软件包安装包,Test_1.0.0.201308160536.jar
一月八日至16日:43:09.540:D /扎伊德日志(22737):启动束束Test_1.0.0.201308160536.jar
一月八日至16日:43:09.550:E /扎伊德日志(22737):org.osgi.framework.BundleException:捆绑#5,无法解决:执行环境J2SE-1.5不支持
一月八日至16日:43:10.740:D / gralloc_goldfish(22737):无仿真模拟GPU检测。

更新2:我删除了这条线从我以下@尼尔以下的回答bundle清单,

 束RequiredExecutionEnvironment:J2SE-1.5

但是这导致了以下错误:

  org.osgi.framework.BundleException:捆绑#6启动失败

也许,我不应该交换开始的框架和起始束的顺序。下面是我的更新LogCat中。

  08-16 17:02:33.855:E /跟踪(28805):错误打开跟踪文件:没有这样的文件或目录(2)
08-16 17:02:35.111:我/的System.out(28805):在这里!
08-16 17:02:35.591:D / dalvikvm(28805):GC_CONCURRENT释放199K,11%免费2679K / 2996K,暂停76ms + 93ms,总246ms
08-16 17:02:36.153:D / dalvikvm(28805):GC_CONCURRENT释放268K,13%免费2814K / 3200K,暂停77ms + 141ms,297ms总
08-16 17:02:36.451:D /扎伊德日志(28805):initlevel 1套
08-16 17:02:36.531:D /扎伊德日志(28805):OSGi框架运行,状态:32
08-16 17:02:36.531:D /扎伊德日志(28805):安装捆绑包,Test_1.0.0.201308161323.jar
08-16 17:02:36.611:D /扎伊德日志(28805):软件包安装包,Test_1.0.0.201308161323.jar
08-16 17:02:36.631:D /扎伊德日志(28805):启动束束Test_1.0.0.201308161323.jar
08-16 17:02:36.646:E /扎伊德日志(28805):org.osgi.framework.BundleException:捆绑#6启动失败
08-16 17:02:36.646:E /扎伊德日志(28805):更多:捆绑#6启动失败
08-16 17:02:36.681:W / System.err的(28805):org.osgi.framework.BundleException:捆绑#6启动失败
08-16 17:02:36.681:W / System.err的(28805):在org.knopflerfish.framework.BundleImpl.start0(BundleImpl.java:421)
08-16 17:02:36.681:W / System.err的(28805):在org.knopflerfish.framework.BundleThread.run(BundleThread.java:145)
08-16 17:02:36.681:W / System.err的(28805):抛出java.lang.ClassNotFoundException:产生的原因bundle_test.Activator
08-16 17:02:36.681:W / System.err的(28805):在org.knopflerfish.framework.BundleClassLoader.findClass(BundleClassLoader.java:218)
08-16 17:02:36.681:W / System.err的(28805):在org.knopflerfish.framework.BundleClassLoader.loadClass(BundleClassLoader.java:347)
08-16 17:02:36.681:W / System.err的(28805):在java.lang.ClassLoader.loadClass(ClassLoader.java:461)
08-16 17:02:36.694:W / System.err的(28805):在org.knopflerfish.framework.BundleImpl.start0(BundleImpl.java:382)
08-16 17:02:36.694:W / System.err的(28805):... 1更多
08-16 17:02:37.282:I /编舞(28805):跳过34帧!该应用程序可能会做它的主线程的工作太多了。
08-16 17:02:37.551:D / gralloc_goldfish(28805):无仿真模拟GPU检测。


解决方案

我只解决错误更新的问题,因为它似乎是第一个问题是固定的(请确认)。

该错误意味着包包括以下要求:

 束RequiredExecutionEnvironment:J2SE-1.5

在换句话说,束称,它需要标准Java 5或更高。这就是所谓的执行环境或EE。通常情况下,OSGi框架检测什么样的Java运行时你都推出它,并将其发布了一组EE中以匹配。例如,如果你在标准的Java 5中运行,该框架发布名为 J2SE-1.5 J2SE-1.4 等的电子工程师回一路JRE-1.0 ,因为Java 5的是与所有这些版本的向后兼容。但是,如果你有一个包断言束RequiredExecutionEnvironment:JavaSE的-1.6 ,并尝试在Java 5中运行它,然后它会无法解析

现在,你想在Android上,这是不标准的Java运行。虽然类似于标准的Java,标准JRE的API许多地方已被删除。因此,需要标准的Java 5捆的不该解决在Android,因为它可能会试图调用不该平台上存在的API。

大概为你做最简单的事情是未解决的包中删除束RequiredExecutionEnvironment 头。这将允许安装它和解决,当然也可能后来与运行时错误失败,如果它确实需要调用从标准JRE是不是在Android present方法。

I am embedding Knopflerfish framework into an android application to start and stop bundles dynamically.

I followed this tutorial, downloaded framework.jar frome this link, and added it to my class path in my eclipse project.

Additionally, below is Activity class, which launches the framework and starts one bundle:

package com.example.knopflerfish_android;

import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.util.Dictionary;
import java.util.Hashtable;
import java.util.Map;
import android.os.Bundle;
import android.app.Activity;
import android.util.Log;
import android.view.Menu;
import android.widget.Toast;

import org.knopflerfish.framework.FrameworkFactoryImpl;
import org.osgi.framework.BundleException;
import org.osgi.framework.ServiceReference;
import org.osgi.framework.launch.Framework;
import org.osgi.framework.launch.FrameworkFactory;
import org.osgi.service.startlevel.StartLevel;




public class MainActivity extends Activity {

private static final String TAG = "Zaid Log";
private Framework mFramework;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);


        System.out.println("here!");

        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(); //STUCK HERE!!


        } catch (BundleException be) {
            // framework initialization failed

            Log.d(TAG, be.getStackTrace().toString());
            Log.d(TAG,"failed to initialize Framework");
        }



        setInitlevel(1);


        installBundle("Bundle_AndroidAPI_1.0.0.201308160327.jar");
        startBundle("Bundle_AndroidAPI_1.0.0.201308160327.jar");
        // install/start other bundles...


        setStartLevel(10);

        try {
            mFramework.start();
        } catch (BundleException be) {
            Log.e(TAG, be.toString());
            // framework start failed
        }

        Log.d(TAG, "OSGi framework running, state: " + mFramework.getState());


      /*  helloServiceReference= context.getServiceReference(HelloService.class.getName());
        HelloService helloService =(HelloService)context.getService(helloServiceReference);
        System.out.println(helloService.sayHello());*/
    }

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        // Inflate the menu; this adds items to the action bar if it is present.
        getMenuInflater().inflate(R.menu.main, menu);
        return true;
    }


    private void startBundle(String bundle) {
        Log.d(TAG, "starting bundle " + bundle);
        InputStream bs;
        try {
            bs = getAssets().open("bundles/" + bundle);
        } catch (IOException e) {
            Log.e(TAG, e.toString());
            return;
        }

        long bid = -1;
        org.osgi.framework.Bundle[] bl = mFramework.getBundleContext().getBundles();
        for (int i = 0; bl != null && i < bl.length; i++) {
            if (bundle.equals(bl[i].getLocation())) {
                bid = bl[i].getBundleId();
            }
        }

        org.osgi.framework.Bundle b = mFramework.getBundleContext().getBundle(bid);
        if (b == null) {
            Log.e(TAG, "can't start bundle " + bundle);

            return;
        }

        try {
            b.start(org.osgi.framework.Bundle.START_ACTIVATION_POLICY);
            Log.d(TAG, "bundle " + b.getSymbolicName() + "/" + b.getBundleId() + "/"
                    + b + " started");
            Toast.makeText(getApplicationContext(),"bundle " + b.getSymbolicName() + "/" + b.getBundleId() + "/"
                    + b + " started" , Toast.LENGTH_SHORT).show();


        } catch (BundleException be) {
            Log.e(TAG, be.toString());
        }

        try {
            bs.close();
        } catch (IOException e) {
            Log.e(TAG, e.toString());
        }
    }

    private void installBundle(String bundle) {
        Log.d(TAG, "installing bundle " + bundle);
        Toast.makeText(getApplicationContext(), "installing bundle", Toast.LENGTH_SHORT).show();

        InputStream bs;
        try {
            bs = getAssets().open("bundles/" + bundle);
        } catch (IOException e) {
            Log.e(TAG, e.toString());
            return;
        }

        try {
            mFramework.getBundleContext().installBundle(bundle, bs);
            Log.d(TAG, "bundle " + bundle + " installed");
            Toast.makeText(getApplicationContext(), "bundle " + bundle + " installed", Toast.LENGTH_SHORT).show();
        } catch (BundleException be) {
            Log.e(TAG, be.toString());
        }

        try {
            bs.close();
        } catch (IOException e) {
            Log.e(TAG, e.toString());
        }
    }

    private void setStartLevel(int startLevel) {
        ServiceReference sr = mFramework.getBundleContext()
            .getServiceReference(StartLevel.class.getName());
        if (sr != null) {
            StartLevel ss =
                (StartLevel)mFramework.getBundleContext().getService(sr);
            ss.setStartLevel(startLevel);
            mFramework.getBundleContext().ungetService(sr);
        } else {
            Log.e(TAG, "No start level service " + startLevel);
        }
    }

    private void setInitlevel(int level) {
        ServiceReference sr = mFramework.getBundleContext()
            .getServiceReference(StartLevel.class.getName());
        if (sr != null) {
            StartLevel ss =
                (StartLevel)mFramework.getBundleContext().getService(sr);
            ss.setInitialBundleStartLevel(level);
            mFramework.getBundleContext().ungetService(sr);
            Log.d(TAG, "initlevel " + level + " set");
        } else {
            Log.e(TAG, "No start level service " + level);
        }
    }


}

As I said in my previous question, according to @ldx in this post, "The patches I submitted for better Android/Dalvik support in Knopflerfish have been merged so patching and recompiling KF should not be necessary anymore:"

and therefore I didn't add anything assuming my code is enough as it is now.

When I run the android application, I don't get any error, instead, I get positive messages on my LogCat saying that my bundle was installed and started. See my log below (I ignore the first 2 lines):

08-15 23:32:08.381: E/Trace(22044): error opening trace file: No such file or directory (2)
08-15 23:32:08.381: E/Trace(22044): error opening trace file: No such file or directory (2)
08-15 23:32:09.441: I/System.out(22044): here!
08-15 23:32:10.320: D/dalvikvm(22044): GC_CONCURRENT freed 172K, 10% free 2695K/2984K, paused 73ms+85ms, total 236ms
08-15 23:32:10.720: D/dalvikvm(22044): GC_CONCURRENT freed 324K, 14% free 2816K/3260K, paused 73ms+85ms, total 214ms
08-15 23:32:10.762: D/Zaid Log(22044): initlevel 1 set
08-15 23:32:10.762: D/Zaid Log(22044): installing bundle Bundle_AndroidAPI_1.0.0.201308160327.jar
08-15 23:32:11.060: D/Zaid Log(22044): bundle Bundle_AndroidAPI_1.0.0.201308160327.jar installed
08-15 23:32:11.080: D/Zaid Log(22044): starting bundle Bundle_AndroidAPI_1.0.0.201308160327.jar
08-15 23:32:11.090: D/Zaid Log(22044): bundle Bundle_AndroidAPI/4/BundleImpl[id=4] started
08-15 23:32:11.140: D/Zaid Log(22044): OSGi framework running, state: 32
08-15 23:32:12.012: D/gralloc_goldfish(22044): Emulator without GPU emulation detected.
08-15 23:32:52.941: I/Choreographer(22044): Skipped 47 frames!  The application may be doing too much work on its main thread.

However, my bundle didn't really start. A message in the start method of the bundle would have shown up on the LogCat if my bundle really started. Below is my bundle start method:

public void start(BundleContext bundleContext) throws Exception {
    Activator.context = bundleContext;


    System.out.println("Hello World. I am the OSGI_Android_Bundle!");


}

Note that my bundle was dexified, but yet it doesn't start in my app. Where did I go wrong?

Update 1: I thought I should swap the starting of the framework with the starting of the bundle. The author of the tutorial starts the bundles first, but I thought to change that because it makes sense to start the framework first, so my updated code has the following:

setInitlevel(1);


// install/start other bundles...


setStartLevel(10);

try {
    mFramework.start();
} catch (BundleException be) {
    Log.e(TAG, be.toString());
    // framework start failed
}

Log.d(TAG, "OSGi framework running, state: " + mFramework.getState());


installBundle("Bundle-Test_1.0.0.201308160536.jar");
startBundle("Bundle-Test_1.0.0.201308160536.jar");

Now, the log doesn't show me that my bundle started as before, but rather it tells me that the execution-environment is not supported. See the updated LogCat below:

08-16 01:43:06.821: I/System.out(22737): here!
08-16 01:43:08.080: D/dalvikvm(22737): GC_CONCURRENT freed 191K, 11% free 2656K/2968K, paused 35ms+18ms, total 155ms
08-16 01:43:09.010: D/dalvikvm(22737): GC_CONCURRENT freed 276K, 13% free 2806K/3200K, paused 25ms+15ms, total 110ms
08-16 01:43:09.238: D/Zaid Log(22737): initlevel 1 set
08-16 01:43:09.300: D/Zaid Log(22737): OSGi framework running, state: 32
08-16 01:43:09.300: D/Zaid Log(22737): installing bundle Bundle-Test_1.0.0.201308160536.jar
08-16 01:43:09.530: D/Zaid Log(22737): bundle Bundle-Test_1.0.0.201308160536.jar installed
08-16 01:43:09.540: D/Zaid Log(22737): starting bundle Bundle-Test_1.0.0.201308160536.jar
08-16 01:43:09.550: E/Zaid Log(22737): org.osgi.framework.BundleException: Bundle#5, unable to resolve: Execution environment 'J2SE-1.5' is not supported
08-16 01:43:10.740: D/gralloc_goldfish(22737): Emulator without GPU emulation detected.

Update 2: I removed this line from my bundle MANIFEST following @Neil's answer below,

Bundle-RequiredExecutionEnvironment: J2SE-1.5

but this resulted in the following error:

 org.osgi.framework.BundleException: Bundle#6 start failed

Perhaps, I shouldn't have swapped the order of starting the framework and starting the bundle. Below is my updated LogCat.

08-16 17:02:33.855: E/Trace(28805): error opening trace file: No such file or directory (2)
08-16 17:02:35.111: I/System.out(28805): here!
08-16 17:02:35.591: D/dalvikvm(28805): GC_CONCURRENT freed 199K, 11% free 2679K/2996K, paused 76ms+93ms, total 246ms
08-16 17:02:36.153: D/dalvikvm(28805): GC_CONCURRENT freed 268K, 13% free 2814K/3200K, paused 77ms+141ms, total 297ms
08-16 17:02:36.451: D/Zaid Log(28805): initlevel 1 set
08-16 17:02:36.531: D/Zaid Log(28805): OSGi framework running, state: 32
08-16 17:02:36.531: D/Zaid Log(28805): installing bundle Bundle-Test_1.0.0.201308161323.jar
08-16 17:02:36.611: D/Zaid Log(28805): bundle Bundle-Test_1.0.0.201308161323.jar installed
08-16 17:02:36.631: D/Zaid Log(28805): starting bundle Bundle-Test_1.0.0.201308161323.jar
08-16 17:02:36.646: E/Zaid Log(28805): org.osgi.framework.BundleException: Bundle#6 start failed
08-16 17:02:36.646: E/Zaid Log(28805): More:Bundle#6 start failed
08-16 17:02:36.681: W/System.err(28805): org.osgi.framework.BundleException: Bundle#6 start failed
08-16 17:02:36.681: W/System.err(28805):    at org.knopflerfish.framework.BundleImpl.start0(BundleImpl.java:421)
08-16 17:02:36.681: W/System.err(28805):    at org.knopflerfish.framework.BundleThread.run(BundleThread.java:145)
08-16 17:02:36.681: W/System.err(28805): Caused by: java.lang.ClassNotFoundException: bundle_test.Activator
08-16 17:02:36.681: W/System.err(28805):    at org.knopflerfish.framework.BundleClassLoader.findClass(BundleClassLoader.java:218)
08-16 17:02:36.681: W/System.err(28805):    at org.knopflerfish.framework.BundleClassLoader.loadClass(BundleClassLoader.java:347)
08-16 17:02:36.681: W/System.err(28805):    at java.lang.ClassLoader.loadClass(ClassLoader.java:461)
08-16 17:02:36.694: W/System.err(28805):    at org.knopflerfish.framework.BundleImpl.start0(BundleImpl.java:382)
08-16 17:02:36.694: W/System.err(28805):    ... 1 more
08-16 17:02:37.282: I/Choreographer(28805): Skipped 34 frames!  The application may be doing too much work on its main thread.
08-16 17:02:37.551: D/gralloc_goldfish(28805): Emulator without GPU emulation detected.

解决方案

I'll only address the error in your updated question, since it seems the first problem was fixed (please confirm).

The error means that a bundle includes the following requirement:

Bundle-RequiredExecutionEnvironment: J2SE-1.5

In other words, the bundle asserts that it requires standard Java 5 or higher. This is known as the Execution Environment or EE. Normally the OSGi Framework detects what kind of Java runtime you have launched it on, and it publishes a set of EEs to match that. For example if you run on standard Java 5, the framework publishes the EEs named J2SE-1.5, J2SE-1.4 etc all the way back to JRE-1.0, because Java 5 is backwards-compatible with all those versions. However if you have a bundle that asserts Bundle-RequiredExecutionEnvironment: JavaSE-1.6 and you try to run it on Java 5 then it will fail to resolve.

Now, you are trying to run on Android, which is not standard Java. While similar to standard Java, many parts of the standard JRE APIs have been removed. Therefore a bundle that requires standard Java 5 should not resolve on Android, because it may attempt to call APIs that do not exist on that platform.

Probably the easiest thing for you to do is remove the Bundle-RequiredExecutionEnvironment header from the bundle that is not resolving. That will allow it to install and resolve, but of course it may later fail with runtime errors if it really does need to call methods from the standard JRE that are not present on Android.

这篇关于在开始嵌入到Android的Knopflerfish一个Bundle不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆