0

我将 Apache Felix 嵌入到一个 android 应用程序中。启动和停止捆绑包工作正常。但我想通过读取另一个包文件来更新包。这是我的代码:

bundle1 = bundleContext1.installBundle("file:sdcard/Download/AndroidImageViewer_1.0.0.201308221559.jar");
            bundle1.start();
            bundle1.stop();
            try {
                bundle1.update(new FileInputStream(new File("file:sdcard/Download/AndroidVideoPlayer_1.0.0.201308231205.jar")));
            } catch (FileNotFoundException e) {e.printStackTrace();}
            bundle1.start();

我希望这可以工作,并且我的捆绑包将得到更新,但不幸的是,我收到了以下错误:

    java.io.FileNotFoundException: /file:sdcard/Download/AndroidVideoPlayer_1.0.0.201308231205.jar (No such file or directory)
    at org.apache.harmony.luni.platform.OSFileSystem.open(Native Method)
    at dalvik.system.BlockGuard$WrappedFileSystem.open(BlockGuard.java:239)

此异常发生在以下行:

bundle1.update(new FileInputStream(new File("file:sdcard/Download/AndroidVideoPlayer_1.0.0.201308231205.jar")));

我完全确定该捆绑包AndroidVideoPlayer_1.0.0.201308231205.jar存在于下载目录中,并且我之前尝试过启动它并且它运行良好。我很困惑。有什么帮助吗?谢谢。

4

1 回答 1

1

啊,您正在从 URL 创建一个 File 对象!

 new File("file:sdcard/Download/AndroidVideoPlayer_1.0.0.201308231205.jar"))

试试这个

 File file = new File( "sdcard/Download/AndroidVideoPlayer_1.0.0.201308231205.jar" );
 context.update( new FileInputStream(file));

或者

 context.update( new URL("file:sdcard/Download/AndroidVideoPlayer_1.0.0.201308231205.jar").openStream());
于 2013-09-02T11:20:32.960 回答