Android ZXing集成错误

时间:2013-03-06 15:01:14

标签: android zxing

我是学生,作为我在学校的android项目的一部分,我需要包含条形码应用程序。我已经明确遵循了

中给出的说明

http://damianflannery.wordpress.com/2011/06/13/integrate-zxing-barcode-scanner-into-your-android-app-natively-using-eclipse/

整合ZXing。我在3个类中有错误,CaptureActivityHandler,DecodeHandler和SearchBookContentsActivity,它们通过将switch-case语句更改为if-else来解决,如下所示:

if(message.what==R.id.decode){
        decode((byte[]) message.obj, message.arg1, message.arg2);
    }
    else if(message.what==R.id.quit){
        running = false;
        Looper.myLooper().quit();
    }

在我的应用程序中,按下按钮,条形码扫描仪的意图应该开始。但我只是得到一个错误,说我的申请已停止。 logcat消息如下:

03-06 20:18:58.631: D/dalvikvm(13812): Late-enabling CheckJNI
03-06 20:18:58.691: I/dalvikvm(13812): Turning on JNI app bug workarounds for target SDK version 10...
03-06 20:18:59.771: D/dalvikvm(13812): GC_FOR_ALLOC freed 57K, 3% free 8839K/9091K, paused 58ms
03-06 20:19:00.441: I/dalvikvm-heap(13812): Grow heap (frag case) to 11.692MB for 3145744-byte allocation
03-06 20:19:00.801: D/dalvikvm(13812): GC_CONCURRENT freed 1K, 3% free 11910K/12231K, paused 326ms+1ms
03-06 20:19:01.881: D/TextLayoutCache(13812): Using debug level: 0 - Debug Enabled: 0
03-06 20:19:06.201: D/dalvikvm(13812): GC_CONCURRENT freed 3118K, 25% free 9768K/12999K, paused 17ms+40ms
03-06 20:19:06.301: D/dalvikvm(13812): GC_FOR_ALLOC freed 4K, 23% free 10123K/12999K, paused 91ms
03-06 20:19:06.521: D/dalvikvm(13812): GC_FOR_ALLOC freed <1K, 20% free 10486K/12999K, paused 79ms
03-06 20:19:15.621: W/dalvikvm(13812): VFY: unable to resolve static field 1373 (ISSUE_NUMBER) in Lcom/google/zxing/ResultMetadataType;
03-06 20:19:15.621: D/dalvikvm(13812): VFY: replacing opcode 0x62 at 0x0017
03-06 20:19:15.621: W/dalvikvm(13812): VFY: unable to find class referenced in signature (Lcom/google/zxing/Result;)
03-06 20:19:15.651: W/dalvikvm(13812): VFY: unable to find class referenced in signature (Lcom/google/zxing/ResultPoint;)
03-06 20:19:15.651: W/dalvikvm(13812): VFY: unable to find class referenced in signature (Lcom/google/zxing/ResultPoint;)
03-06 20:19:15.651: I/dalvikvm(13812): Could not find method com.google.zxing.ResultPoint.getX, referenced from method com.google.zxing.client.android.CaptureActivity.drawLine
03-06 20:19:15.651: W/dalvikvm(13812): VFY: unable to resolve virtual method 3917: Lcom/google/zxing/ResultPoint;.getX ()F
03-06 20:19:15.651: D/dalvikvm(13812): VFY: replacing opcode 0x6e at 0x0000
03-06 20:19:15.651: W/dalvikvm(13812): VFY: unable to find class referenced in signature (Lcom/google/zxing/Result;)
03-06 20:19:15.651: I/dalvikvm(13812): Could not find method com.google.zxing.Result.getResultPoints, referenced from method com.google.zxing.client.android.CaptureActivity.drawResultPoints
03-06 20:19:15.651: W/dalvikvm(13812): VFY: unable to resolve virtual method 3913: Lcom/google/zxing/Result;.getResultPoints ()[Lcom/google/zxing/ResultPoint;
03-06 20:19:15.651: D/dalvikvm(13812): VFY: replacing opcode 0x6e at 0x0003
03-06 20:19:15.661: W/dalvikvm(13812): VFY: unable to find class referenced in signature (Lcom/google/zxing/Result;)
03-06 20:19:15.671: I/dalvikvm(13812): Could not find method com.google.zxing.Result.toString, referenced from method com.google.zxing.client.android.CaptureActivity.handleDecodeExternally
03-06 20:19:15.671: W/dalvikvm(13812): VFY: unable to resolve virtual method 3916: Lcom/google/zxing/Result;.toString ()Ljava/lang/String;
03-06 20:19:15.671: D/dalvikvm(13812): VFY: replacing opcode 0x74 at 0x0053
03-06 20:19:15.671: W/dalvikvm(13812): VFY: unable to find class referenced in signature (Lcom/google/zxing/Result;)
03-06 20:19:15.681: I/dalvikvm(13812): Could not find method com.google.zxing.Result.getBarcodeFormat, referenced from method com.google.zxing.client.android.CaptureActivity.handleDecodeInternally
03-06 20:19:15.681: W/dalvikvm(13812): VFY: unable to resolve virtual method 3910: Lcom/google/zxing/Result;.getBarcodeFormat ()Lcom/google/zxing/BarcodeFormat;
03-06 20:19:15.681: D/dalvikvm(13812): VFY: replacing opcode 0x74 at 0x004a
03-06 20:19:15.681: W/dalvikvm(13812): VFY: unable to find class referenced in signature (Lcom/google/zxing/Result;)
03-06 20:19:15.691: W/dalvikvm(13812): VFY: unable to find class referenced in signature (Lcom/google/zxing/Result;)
03-06 20:19:15.691: W/dalvikvm(13812): VFY: unable to find class referenced in signature (Lcom/google/zxing/Result;)
03-06 20:19:15.701: W/dalvikvm(13812): VFY: unable to find class referenced in signature (Lcom/google/zxing/Result;)
03-06 20:19:15.701: W/dalvikvm(13812): VFY: unable to find class referenced in signature (Lcom/google/zxing/Result;)
03-06 20:19:15.701: W/dalvikvm(13812): VFY: unable to find class referenced in signature (Lcom/google/zxing/Result;)
03-06 20:19:15.701: W/dalvikvm(13812): VFY: unable to find class referenced in signature (Lcom/google/zxing/Result;)
03-06 20:19:15.701: W/dalvikvm(13812): VFY: unable to find class referenced in signature (Lcom/google/zxing/Result;)
03-06 20:19:15.701: W/dalvikvm(13812): VFY: unable to find class referenced in signature (Lcom/google/zxing/Result;)
03-06 20:19:15.711: W/dalvikvm(13812): VFY: unable to find class referenced in signature (Lcom/google/zxing/Result;)
03-06 20:19:15.721: W/dalvikvm(13812): VFY: unable to find class referenced in signature (Lcom/google/zxing/Result;)
03-06 20:19:15.721: W/dalvikvm(13812): VFY: unable to find class referenced in signature (Lcom/google/zxing/Result;)
03-06 20:19:15.751: W/dalvikvm(13812): Exception Ljava/lang/NoClassDefFoundError; thrown while initializing Lcom/google/zxing/client/android/CaptureActivity;
03-06 20:19:15.751: W/dalvikvm(13812): Class init failed in newInstance call (Lcom/google/zxing/client/android/CaptureActivity;)
03-06 20:19:15.751: D/AndroidRuntime(13812): Shutting down VM
03-06 20:19:15.751: W/dalvikvm(13812): threadid=1: thread exiting with uncaught exception (group=0x2b542210)
03-06 20:19:15.751: E/AndroidRuntime(13812): FATAL EXCEPTION: main
03-06 20:19:15.751: E/AndroidRuntime(13812): java.lang.ExceptionInInitializerError
03-06 20:19:15.751: E/AndroidRuntime(13812):    at java.lang.Class.newInstanceImpl(Native Method)
03-06 20:19:15.751: E/AndroidRuntime(13812):    at java.lang.Class.newInstance(Class.java:1319)
03-06 20:19:15.751: E/AndroidRuntime(13812):    at android.app.Instrumentation.newActivity(Instrumentation.java:1023)
03-06 20:19:15.751: E/AndroidRuntime(13812):    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1882)
03-06 20:19:15.751: E/AndroidRuntime(13812):    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1992)
03-06 20:19:15.751: E/AndroidRuntime(13812):    at android.app.ActivityThread.access$600(ActivityThread.java:127)
03-06 20:19:15.751: E/AndroidRuntime(13812):    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1158)
03-06 20:19:15.751: E/AndroidRuntime(13812):    at android.os.Handler.dispatchMessage(Handler.java:99)
03-06 20:19:15.751: E/AndroidRuntime(13812):    at android.os.Looper.loop(Looper.java:137)
03-06 20:19:15.751: E/AndroidRuntime(13812):    at android.app.ActivityThread.main(ActivityThread.java:4441)
03-06 20:19:15.751: E/AndroidRuntime(13812):    at java.lang.reflect.Method.invokeNative(Native Method)
03-06 20:19:15.751: E/AndroidRuntime(13812):    at java.lang.reflect.Method.invoke(Method.java:511)
03-06 20:19:15.751: E/AndroidRuntime(13812):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
03-06 20:19:15.751: E/AndroidRuntime(13812):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
03-06 20:19:15.751: E/AndroidRuntime(13812):    at dalvik.system.NativeStart.main(Native Method)
03-06 20:19:15.751: E/AndroidRuntime(13812): Caused by: java.lang.NoClassDefFoundError: com.google.zxing.ResultMetadataType
03-06 20:19:15.751: E/AndroidRuntime(13812):    at com.google.zxing.client.android.CaptureActivity.<clinit>(CaptureActivity.java:107)
03-06 20:19:15.751: E/AndroidRuntime(13812):    ... 15 more

有人可以帮帮我吗?我在StackOverflow上经历了很多帖子,但未能找到答案。

2 个答案:

答案 0 :(得分:2)

如果您真的想要嵌入zxing而不是将其与意图集成,我建议使用您可以找到的开箱即用的库here: https://github.com/kennydude/zxing-lib

正如马克所说,最常见的方法是与他们的应用程序集成意图。

答案 1 :(得分:1)

您需要按照链接

的步骤进行操作

http://www.androidaz.com/development/zxing-qr-reader-direct-integration

您可以从

下载core.jar

http://repo1.maven.org/maven2/com/google/zxing/core/2.2/

以上对我有用,如果你的程序仍然崩溃只需将core-2.2.jar放入libs并清理你的项目