سؤال

I'm attempting to use the jCIFS version 1.3.17 JAR file in my Android app. The application compiles correctly and deploys to my phone. When my application tries to use the jCIFS library I receive the following error message:

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?

هل كانت مفيدة؟

المحلول

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:

Step #1: Create a libs/ directory in your project

Step #2: Put the JAR in the libs/ directory

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.

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 (e.g., via manual build path adjustments) but the Android tools not knowing about the JAR.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top