java – Android – 安装Apache Commons VFS – 问题

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

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

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

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项目,有什么特别需要做的吗?任何指针都将非常感激.

最佳答案 我有完全相同的问题.

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

一旦我从WEB-INF / lib目录中删除了S3提供程序JAR,一切正常.

点赞