简体   繁体   English

在Android中使用jCIFS时的VerifyError

[英]VerifyError when using jCIFS in Android

I'm attempting to use the jCIFS version 1.3.17 JAR file in my Android app. 我正在尝试在我的Android应用程序中使用jCIFS版本1.3.17 JAR文件。 The application compiles correctly and deploys to my phone. 该应用程序正确编译并部署到我的手机。 When my application tries to use the jCIFS library I receive the following error message: 当我的应用程序尝试使用jCIFS库时,我收到以下错误消息:

E/dalvikvm( 3176): Could not find class 'jcifs.smb.SmbFile', referenced from method com.test.androidapp.service.BackgroundService.copyFiles
W/dalvikvm( 3176): VFY: unable to resolve new-instance 94 (Ljcifs/smb/SmbFile;) in Lcom/test/androidapp/service/BackgroundService;
D/dalvikvm( 3176): VFY: replacing opcode 0x22 at 0x0001
W/dalvikvm( 3176): VFY: unable to resolve exception class 93 (Ljcifs/smb/SmbException;)
W/dalvikvm( 3176): VFY: unable to find exception handler at addr 0x6c
W/dalvikvm( 3176): VFY:  rejected Lcom/test/androidapp/service/BackgroundService;.copyFiles ()Z
W/dalvikvm( 3176): VFY:  rejecting opcode 0x0d at 0x006c
W/dalvikvm( 3176): VFY:  rejected Lcom/test/androidapp/service/BackgroundService;.copyFiles ()Z
W/dalvikvm( 3176): Verifier rejected class Lcom/test/androidapp/service/BackgroundService;
W/dalvikvm( 3176): Class init failed in newInstance call (Lcom/test/androidapp/service/BackgroundService;)
D/AndroidRuntime( 3176): Shutting down VM
W/dalvikvm( 3176): threadid=1: thread exiting with uncaught exception (group=0x4001d5a0)
E/AndroidRuntime( 3176): FATAL EXCEPTION: main
E/AndroidRuntime( 3176): java.lang.VerifyError: com.test.androidapp.service.BackgroundService
E/AndroidRuntime( 3176):    at java.lang.Class.newInstanceImpl(Native Method)
E/AndroidRuntime( 3176):    at java.lang.Class.newInstance(Class.java:1409)
E/AndroidRuntime( 3176):    at android.app.ActivityThread.handleCreateService(ActivityThread.java:2174)
E/AndroidRuntime( 3176):    at android.app.ActivityThread.access$2500(ActivityThread.java:132)
E/AndroidRuntime( 3176):    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1102)
E/AndroidRuntime( 3176):    at android.os.Handler.dispatchMessage(Handler.java:99)
E/AndroidRuntime( 3176):    at android.os.Looper.loop(Looper.java:150)
E/AndroidRuntime( 3176):    at android.app.ActivityThread.main(ActivityThread.java:4263)
E/AndroidRuntime( 3176):    at java.lang.reflect.Method.invokeNative(Native Method)
E/AndroidRuntime( 3176):    at java.lang.reflect.Method.invoke(Method.java:507)
E/AndroidRuntime( 3176):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
E/AndroidRuntime( 3176):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
E/AndroidRuntime( 3176):    at dalvik.system.NativeStart.main(Native Method)
W/ActivityManager(  129):   Force finishing activity com.test.androidapp/.activity.MainActivity

Can someone explain why Android isn't finding jCIFS? 有人可以解释为什么Android没有找到jCIFS吗?

Assuming that you are on the latest version of the Android SDK tools (and, if applicable, the ADT plugin for Eclipse), the proper procedure for adding a third-party JAR is: 假设您使用的是最新版本的Android SDK工具(以及适用的Eclipse的ADT插件),添加第三方JAR的正确步骤如下:

Step #1: Create a libs/ directory in your project 步骤1:在项目中创建一个libs/目录

Step #2: Put the JAR in the libs/ directory 步骤#2:将JAR放在libs/目录中

Note that you do not need to mess with build paths or anything -- that is now handled automatically in Eclipse, just as it has been for command-line builds since the beginning. 请注意,您不需要混淆构建路径或任何东西 - 现在可以在Eclipse中自动处理,就像从一开始就用于命令行构建一样。

This error feels like your JAR is available at compile time but is not being packaged in your APK, such as Eclipse knowing about the JAR (eg, via manual build path adjustments) but the Android tools not knowing about the JAR. 这个错误感觉就像你的JAR在编译时可用,但没有打包在你的APK中,比如Eclipse知道JAR(例如,通过手动构建路径调整),但Android工具不了解JAR。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM