zbar 使用报错

java.lang.RuntimeException: An error occured while executing doInBackground()
                      at android.os.AsyncTask$3.done(AsyncTask.java:299)
                      at java.util.concurrent.FutureTask.finishCompletion(FutureTask.java:352)
                      at java.util.concurrent.FutureTask.setException(FutureTask.java:219)
                      at java.util.concurrent.FutureTask.run(FutureTask.java:239)
                      at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:230)
                      at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1080)
                      at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:573)
                      at java.lang.Thread.run(Thread.java:856)
                   Caused by: java.lang.ExceptionInInitializerError
                      at cn.bingoogolapple.qrcode.zbar.ZBarView$1.doInBackground(ZBarView.java:52)
                      at cn.bingoogolapple.qrcode.zbar.ZBarView$1.doInBackground(ZBarView.java:47)
                      at android.os.AsyncTask$2.call(AsyncTask.java:287)
                      at java.util.concurrent.FutureTask.run(FutureTask.java:234)
                      at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:230) 
                      at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1080) 
                      at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:573) 
                      at java.lang.Thread.run(Thread.java:856) 
                   Caused by: java.lang.NoSuchFieldError: no field with name='data' signature='Ljava/lang/Object;' in class Lnet/sourceforge/zbar/Image;
                      at net.sourceforge.zbar.Image.init(Native Method)
                      at net.sourceforge.zbar.Image.(Unknown Source)
                      at cn.bingoogolapple.qrcode.zbar.ZBarView$1.doInBackground(ZBarView.java:52) 
                      at cn.bingoogolapple.qrcode.zbar.ZBarView$1.doInBackground(ZBarView.java:47) 
                      at android.os.AsyncTask$2.call(AsyncTask.java:287) 
                      at java.util.concurrent.FutureTask.run(FutureTask.java:234) 
                      at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:230) 
                      at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1080) 
                      at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:573) 
                      at java.lang.Thread.run(Thread.java:856) 



 解决方案

proguard-rules.pro 中加入  

-keep class net.sourceforge.zbar.** { *; }

你可能感兴趣的:(android)