FileNotFoundEXception in android zxing library

跟風遠走 提交于 2019-12-11 07:58:14

问题


I am using zxing2.0 library for android but I get this exception :, what does it mean ?

10-01 22:20:03.197: E/AndroidRuntime(345): java.lang.RuntimeException: Unable to start activity ComponentInfo{phoenix.metro.uis/com.google.zxing.client.android.CaptureActivity}: android.content.res.Resources$NotFoundException: File res/xml/preferences.xml from drawable resource ID #0x7f050000
10-01 22:20:03.197: E/AndroidRuntime(345):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1647)
10-01 22:20:03.197: E/AndroidRuntime(345):  at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1663)
10-01 22:20:03.197: E/AndroidRuntime(345):  at android.app.ActivityThread.access$1500(ActivityThread.java:117)
10-01 22:20:03.197: E/AndroidRuntime(345):  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:931)
10-01 22:20:03.197: E/AndroidRuntime(345):  at android.os.Handler.dispatchMessage(Handler.java:99)
10-01 22:20:03.197: E/AndroidRuntime(345):  at android.os.Looper.loop(Looper.java:123)
10-01 22:20:03.197: E/AndroidRuntime(345):  at android.app.ActivityThread.main(ActivityThread.java:3683)
10-01 22:20:03.197: E/AndroidRuntime(345):  at java.lang.reflect.Method.invokeNative(Native Method)
10-01 22:20:03.197: E/AndroidRuntime(345):  at java.lang.reflect.Method.invoke(Method.java:507)
10-01 22:20:03.197: E/AndroidRuntime(345):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
10-01 22:20:03.197: E/AndroidRuntime(345):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
10-01 22:20:03.197: E/AndroidRuntime(345):  at dalvik.system.NativeStart.main(Native Method)
10-01 22:20:03.197: E/AndroidRuntime(345): Caused by: android.content.res.Resources$NotFoundException: File res/xml/preferences.xml from drawable resource ID #0x7f050000
10-01 22:20:03.197: E/AndroidRuntime(345):  at android.content.res.Resources.openRawResourceFd(Resources.java:860)
10-01 22:20:03.197: E/AndroidRuntime(345):  at com.google.zxing.client.android.BeepManager.buildMediaPlayer(BeepManager.java:97)
10-01 22:20:03.197: E/AndroidRuntime(345):  at com.google.zxing.client.android.BeepManager.updatePrefs(BeepManager.java:60)
10-01 22:20:03.197: E/AndroidRuntime(345):  at com.google.zxing.client.android.BeepManager.<init>(BeepManager.java:49)
10-01 22:20:03.197: E/AndroidRuntime(345):  at com.google.zxing.client.android.CaptureActivity.onCreate(CaptureActivity.java:165)
10-01 22:20:03.197: E/AndroidRuntime(345):  at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
10-01 22:20:03.197: E/AndroidRuntime(345):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1611)
10-01 22:20:03.197: E/AndroidRuntime(345):  ... 11 more
10-01 22:20:03.197: E/AndroidRuntime(345): Caused by: java.io.FileNotFoundException: This file can not be opened as a file descriptor; it is probably compressed
10-01 22:20:03.197: E/AndroidRuntime(345):  at android.content.res.AssetManager.openNonAssetFdNative(Native Method)
10-01 22:20:03.197: E/AndroidRuntime(345):  at android.content.res.AssetManager.openNonAssetFd(AssetManager.java:427)
10-01 22:20:03.197: E/AndroidRuntime(345):  at android.content.res.Resources.openRawResourceFd(Resources.java:857)
10-01 22:20:03.197: E/AndroidRuntime(345):  ... 17 more

回答1:


Same problem! I fix it by a step-by-step guide in which writer explains very well how to implement a barcode reader/encoder using zxing library. The difference from original manual is that he seems to use his version of library, modified in some point (as he shows in the article) that fixes the problem. Follow his instructions and download his zxing library. It works for me:

michalu zxing barcode



来源:https://stackoverflow.com/questions/12681965/filenotfoundexception-in-android-zxing-library

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!