更新Felix中嵌入到Android应用程序中的捆绑包时显示:“;java.io.FileNotFoundException“;
我正在将ApacheFelix嵌入到android应用程序中。启动和停止捆绑工作正常。但是我想通过读取另一个bundle文件来更新bundle。这是我的密码:更新Felix中嵌入到Android应用程序中的捆绑包时显示:“;java.io.FileNotFoundException“;,android,osgi,bundle,apache-felix,osgi-bundle,Android,Osgi,Bundle,Apache Felix,Osgi Bundle,我正在将ApacheFelix嵌入到android应用程序中。启动和停止捆绑工作正常。但是我想通过读取另一个bundle文件来更新bundle。这是我的密码: bundle1 = bundleContext1.installBundle("file:sdcard/Download/AndroidImageViewer_1.0.0.201308221559.jar"); bundle1.start(); bundle1.stop();
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\u 1.0.0.201308231205.jar
,我以前尝试过启动它,但效果很好。我很困惑。有什么帮助吗?谢谢。啊,您正在从URL创建文件对象
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));
或
您确定url不应以开头吗file://sdcard/...Yes 我敢肯定。事实上,你的方式甚至在启动捆绑包时都不起作用。
context.update( new URL("file:sdcard/Download/AndroidVideoPlayer_1.0.0.201308231205.jar").openStream());