Android - 安装 Apache Commons VFS - 问题

发布于 2025-01-02 23:32:38 字数 5454 浏览 2 评论 0原文

我希望在我的 Android 项目中使用 Apache Commons VFS 库,并已从 http 下载相关文件://commons.apache.org/vfs/download_vfs.cgi。然而。我遇到一些问题。

我已将 commons-vfs2-2.0.jar 文件复制到我的 android 项目的 /libs/ 子目录中,并在 Eclipse 中的 java 构建路径中引用它。我还引用了 Commons VFS 使用的 Commons Logging 库 (http://commons.apache.org/vfs/download.html)。

一切都编译得很好,但是当我尝试下面的代码行时,

FileSystemManager fsManager = VFS.getManager();

我得到了一个异常。这是堆栈跟踪:

02-06 16:22:29.724: ERROR/Fatal Error(20515): Could not create a file system manager   of class "org.apache.commons.vfs2.impl.StandardFileSystemManager".
02-06 16:22:29.724: ERROR/Fatal Error(20515): org.apache.commons.vfs2.FileSystemException: Could not create a file system manager of class "org.apache.commons.vfs2.impl.StandardFileSystemManager".
02-06 16:22:29.724: ERROR/Fatal Error(20515):     at org.apache.commons.vfs2.VFS.createManager(VFS.java:99)
02-06 16:22:29.724: ERROR/Fatal Error(20515):     at org.apache.commons.vfs2.VFS.getManager(VFS.java:50)
02-06 16:22:29.724: ERROR/Fatal Error(20515):     at gymApp.gymAppPackage.Utility.test(Utility.java:391)
02-06 16:22:29.724: ERROR/Fatal Error(20515):     at gymApp.gymAppPackage.HomeActivity.onCreate(HomeActivity.java:51)
02-06 16:22:29.724: ERROR/Fatal Error(20515):     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
02-06 16:22:29.724: ERROR/Fatal Error(20515):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2466)
02-06 16:22:29.724: ERROR/Fatal Error(20515):     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2519)
02-06 16:22:29.724: ERROR/Fatal Error(20515):     at android.app.ActivityThread.access$2200(ActivityThread.java:123)
02-06 16:22:29.724: ERROR/Fatal Error(20515):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1870)
02-06 16:22:29.724: ERROR/Fatal Error(20515):     at android.os.Handler.dispatchMessage(Handler.java:99)
02-06 16:22:29.724: ERROR/Fatal Error(20515):     at android.os.Looper.loop(Looper.java:123)
02-06 16:22:29.724: ERROR/Fatal Error(20515):     at android.app.ActivityThread.main(ActivityThread.java:4370)
02-06 16:22:29.724: ERROR/Fatal Error(20515):     at java.lang.reflect.Method.invokeNative(Native Method)
02-06 16:22:29.724: ERROR/Fatal Error(20515):     at java.lang.reflect.Method.invoke(Method.java:521)
02-06 16:22:29.724: ERROR/Fatal Error(20515):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
02-06 16:22:29.724: ERROR/Fatal Error(20515):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
02-06 16:22:29.724: ERROR/Fatal Error(20515):     at dalvik.system.NativeStart.main(Native Method)
02-06 16:22:29.724: ERROR/Fatal Error(20515): Caused by: org.apache.commons.vfs2.FileSystemException: Could not load VFS configuration from "jar:file:/data/app/gymApp.gymAppPackage.apk!/org/apache/commons/vfs2/impl/providers.xml".
02-06 16:22:29.724: ERROR/Fatal Error(20515):     at org.apache.commons.vfs2.impl.StandardFileSystemManager.configure(StandardFileSystemManager.java:199)
02-06 16:22:29.724: ERROR/Fatal Error(20515):     at org.apache.commons.vfs2.impl.StandardFileSystemManager.init(StandardFileSystemManager.java:123)
02-06 16:22:29.724: ERROR/Fatal Error(20515):     at java.lang.reflect.Method.invokeNative(Native Method)
02-06 16:22:29.724: ERROR/Fatal Error(20515):     at java.lang.reflect.Method.invoke(Method.java:521)
02-06 16:22:29.724: ERROR/Fatal Error(20515):     at org.apache.commons.vfs2.VFS.createManager(VFS.java:88)
02-06 16:22:29.724: ERROR/Fatal Error(20515):     ... 16 more
02-06 16:22:29.724: ERROR/Fatal Error(20515): Caused by: org.apache.commons.vfs2.FileSystemException: Could not create file provider of class "org.apache.commons.vfs2.provider.local.DefaultLocalFileProvider".
02-06 16:22:29.724: ERROR/Fatal Error(20515):     at org.apache.commons.vfs2.impl.StandardFileSystemManager.createInstance(StandardFileSystemManager.java:490)
02-06 16:22:29.724: ERROR/Fatal Error(20515):     at org.apache.commons.vfs2.impl.StandardFileSystemManager.addProvider(StandardFileSystemManager.java:371)
02-06 16:22:29.724: ERROR/Fatal Error(20515):     at org.apache.commons.vfs2.impl.StandardFileSystemManager.configure(StandardFileSystemManager.java:270)
02-06 16:22:29.724: ERROR/Fatal Error(20515):     at org.apache.commons.vfs2.impl.StandardFileSystemManager.configure(StandardFileSystemManager.java:195)
02-06 16:22:29.724: ERROR/Fatal Error(20515):     ... 20 more
02-06 16:22:29.724: ERROR/Fatal Error(20515): Caused by: java.lang.ClassNotFoundException: org.apache.commons.vfs2.provider.local.DefaultLocalFileProvider in loader dalvik.system.PathClassLoader@400264d8
02-06 16:22:29.724: ERROR/Fatal Error(20515):     at dalvik.system.PathClassLoader.findClass(PathClassLoader.java:243)
02-06 16:22:29.724: ERROR/Fatal Error(20515):     at java.lang.ClassLoader.loadClass(ClassLoader.java:573)
02-06 16:22:29.724: ERROR/Fatal Error(20515):     at java.lang.ClassLoader.loadClass(ClassLoader.java:532)
02-06 16:22:29.724: ERROR/Fatal Error(20515):     at org.apache.commons.vfs2.impl.StandardFileSystemManager.createInstance(StandardFileSystemManager.java:485)
02-06 16:22:29.724: ERROR/Fatal Error(20515):     ... 23 more

安装似乎有一些基本问题,但我不确定它是什么(Java 不是我的第一语言;)。鉴于它是一个 Android 项目,有什么特别需要做的吗?任何指示将不胜感激。

I'm hoping to use the Apache Commons VFS library in my Android project and have downloaded the relevant files from http://commons.apache.org/vfs/download_vfs.cgi. However. I'm getting some issues.

I've copied the commons-vfs2-2.0.jar file into a /libs/ subdirectory of my android project and referenced it in the java build path in Eclipse. I have also referenced the Commons Logging library which is used by Commons VFS (http://commons.apache.org/vfs/download.html).

Everything compiles fine, but as soon as I try the following line of code

FileSystemManager fsManager = VFS.getManager();

I get an exception. Here's the stack trace:

02-06 16:22:29.724: ERROR/Fatal Error(20515): Could not create a file system manager   of class "org.apache.commons.vfs2.impl.StandardFileSystemManager".
02-06 16:22:29.724: ERROR/Fatal Error(20515): org.apache.commons.vfs2.FileSystemException: Could not create a file system manager of class "org.apache.commons.vfs2.impl.StandardFileSystemManager".
02-06 16:22:29.724: ERROR/Fatal Error(20515):     at org.apache.commons.vfs2.VFS.createManager(VFS.java:99)
02-06 16:22:29.724: ERROR/Fatal Error(20515):     at org.apache.commons.vfs2.VFS.getManager(VFS.java:50)
02-06 16:22:29.724: ERROR/Fatal Error(20515):     at gymApp.gymAppPackage.Utility.test(Utility.java:391)
02-06 16:22:29.724: ERROR/Fatal Error(20515):     at gymApp.gymAppPackage.HomeActivity.onCreate(HomeActivity.java:51)
02-06 16:22:29.724: ERROR/Fatal Error(20515):     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
02-06 16:22:29.724: ERROR/Fatal Error(20515):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2466)
02-06 16:22:29.724: ERROR/Fatal Error(20515):     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2519)
02-06 16:22:29.724: ERROR/Fatal Error(20515):     at android.app.ActivityThread.access$2200(ActivityThread.java:123)
02-06 16:22:29.724: ERROR/Fatal Error(20515):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1870)
02-06 16:22:29.724: ERROR/Fatal Error(20515):     at android.os.Handler.dispatchMessage(Handler.java:99)
02-06 16:22:29.724: ERROR/Fatal Error(20515):     at android.os.Looper.loop(Looper.java:123)
02-06 16:22:29.724: ERROR/Fatal Error(20515):     at android.app.ActivityThread.main(ActivityThread.java:4370)
02-06 16:22:29.724: ERROR/Fatal Error(20515):     at java.lang.reflect.Method.invokeNative(Native Method)
02-06 16:22:29.724: ERROR/Fatal Error(20515):     at java.lang.reflect.Method.invoke(Method.java:521)
02-06 16:22:29.724: ERROR/Fatal Error(20515):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
02-06 16:22:29.724: ERROR/Fatal Error(20515):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
02-06 16:22:29.724: ERROR/Fatal Error(20515):     at dalvik.system.NativeStart.main(Native Method)
02-06 16:22:29.724: ERROR/Fatal Error(20515): Caused by: org.apache.commons.vfs2.FileSystemException: Could not load VFS configuration from "jar:file:/data/app/gymApp.gymAppPackage.apk!/org/apache/commons/vfs2/impl/providers.xml".
02-06 16:22:29.724: ERROR/Fatal Error(20515):     at org.apache.commons.vfs2.impl.StandardFileSystemManager.configure(StandardFileSystemManager.java:199)
02-06 16:22:29.724: ERROR/Fatal Error(20515):     at org.apache.commons.vfs2.impl.StandardFileSystemManager.init(StandardFileSystemManager.java:123)
02-06 16:22:29.724: ERROR/Fatal Error(20515):     at java.lang.reflect.Method.invokeNative(Native Method)
02-06 16:22:29.724: ERROR/Fatal Error(20515):     at java.lang.reflect.Method.invoke(Method.java:521)
02-06 16:22:29.724: ERROR/Fatal Error(20515):     at org.apache.commons.vfs2.VFS.createManager(VFS.java:88)
02-06 16:22:29.724: ERROR/Fatal Error(20515):     ... 16 more
02-06 16:22:29.724: ERROR/Fatal Error(20515): Caused by: org.apache.commons.vfs2.FileSystemException: Could not create file provider of class "org.apache.commons.vfs2.provider.local.DefaultLocalFileProvider".
02-06 16:22:29.724: ERROR/Fatal Error(20515):     at org.apache.commons.vfs2.impl.StandardFileSystemManager.createInstance(StandardFileSystemManager.java:490)
02-06 16:22:29.724: ERROR/Fatal Error(20515):     at org.apache.commons.vfs2.impl.StandardFileSystemManager.addProvider(StandardFileSystemManager.java:371)
02-06 16:22:29.724: ERROR/Fatal Error(20515):     at org.apache.commons.vfs2.impl.StandardFileSystemManager.configure(StandardFileSystemManager.java:270)
02-06 16:22:29.724: ERROR/Fatal Error(20515):     at org.apache.commons.vfs2.impl.StandardFileSystemManager.configure(StandardFileSystemManager.java:195)
02-06 16:22:29.724: ERROR/Fatal Error(20515):     ... 20 more
02-06 16:22:29.724: ERROR/Fatal Error(20515): Caused by: java.lang.ClassNotFoundException: org.apache.commons.vfs2.provider.local.DefaultLocalFileProvider in loader dalvik.system.PathClassLoader@400264d8
02-06 16:22:29.724: ERROR/Fatal Error(20515):     at dalvik.system.PathClassLoader.findClass(PathClassLoader.java:243)
02-06 16:22:29.724: ERROR/Fatal Error(20515):     at java.lang.ClassLoader.loadClass(ClassLoader.java:573)
02-06 16:22:29.724: ERROR/Fatal Error(20515):     at java.lang.ClassLoader.loadClass(ClassLoader.java:532)
02-06 16:22:29.724: ERROR/Fatal Error(20515):     at org.apache.commons.vfs2.impl.StandardFileSystemManager.createInstance(StandardFileSystemManager.java:485)
02-06 16:22:29.724: ERROR/Fatal Error(20515):     ... 23 more

It seems like something basic is wrong with the installation, but I'm not sure what it is (Java is not my first language ;). Is there something special that needs to be done given that it is an Android project? Any pointers would be much appreciated.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

眼藏柔 2025-01-09 23:32:38

我有完全相同的问题。

我掌握了 commons-vfs 源代码,并通过代码将错误跟踪到插件初始化中 - 基本上,我们的 S3 提供程序插件正在初始化,即使不需要它。一些时髦的类加载器在 S3 JAR 中发现 vfs-providers.xml 并尝试初始化它,即使 URL 不需要该插件。

当我从 WEB-INF/lib 目录中删除 S3 提供程序 JAR 后,一切正常。

I had exactly the same problem.

I got hold of the commons-vfs source code and traced the error through the code into the plugin initialisation - basically, our S3 provider plugin was being initialised, even though it wasn’t needed. Some funky class loader was spotting vfs-providers.xml in the S3 JAR and trying to initialise it, even though the URL didn’t require the plugin.

Once I removed the S3 provider JAR from the WEB-INF/lib directory, it all worked fine.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文