Android ZXing 实现

发布于 2024-12-01 06:16:25 字数 4716 浏览 2 评论 0原文

我使用 ZXing 源代码创建了一个项目。效果很好。

当我将包名称更改

 com.google.zxing.client.android 

 com.google.zxing.client.android.vofox

但它在真实设备(HTC Wildfire)中显示错误

后,它在 eclipse 模拟器中没有错误。我的 logcat 文件如下所示。

08-23 17:13:58.899: ERROR/AndroidRuntime(9816): FATAL EXCEPTION: main
08-23 17:13:58.899: ERROR/AndroidRuntime(9816): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.google.zxing.client.android.vofox/com.google.zxing.client.android.vofox.CaptureActivity}: android.view.InflateException: Binary XML file line #26: Error inflating class com.google.zxing.client.android.ViewfinderView
08-23 17:13:58.899: ERROR/AndroidRuntime(9816):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2781)
08-23 17:13:58.899: ERROR/AndroidRuntime(9816):     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2797)
08-23 17:13:58.899: ERROR/AndroidRuntime(9816):     at android.app.ActivityThread.access$2300(ActivityThread.java:135)
08-23 17:13:58.899: ERROR/AndroidRuntime(9816):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2132)
08-23 17:13:58.899: ERROR/AndroidRuntime(9816):     at android.os.Handler.dispatchMessage(Handler.java:99)
08-23 17:13:58.899: ERROR/AndroidRuntime(9816):     at android.os.Looper.loop(Looper.java:143)
08-23 17:13:58.899: ERROR/AndroidRuntime(9816):     at android.app.ActivityThread.main(ActivityThread.java:4914)
08-23 17:13:58.899: ERROR/AndroidRuntime(9816):     at java.lang.reflect.Method.invokeNative(Native Method)
08-23 17:13:58.899: ERROR/AndroidRuntime(9816):     at java.lang.reflect.Method.invoke(Method.java:521)
08-23 17:13:58.899: ERROR/AndroidRuntime(9816):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:858)
08-23 17:13:58.899: ERROR/AndroidRuntime(9816):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
08-23 17:13:58.899: ERROR/AndroidRuntime(9816):     at dalvik.system.NativeStart.main(Native Method)
08-23 17:13:58.899: ERROR/AndroidRuntime(9816): Caused by: android.view.InflateException: Binary XML file line #26: Error inflating class com.google.zxing.client.android.ViewfinderView
08-23 17:13:58.899: ERROR/AndroidRuntime(9816):     at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:576)
08-23 17:13:58.899: ERROR/AndroidRuntime(9816):     at android.view.LayoutInflater.rInflate(LayoutInflater.java:618)
08-23 17:13:58.899: ERROR/AndroidRuntime(9816):     at android.view.LayoutInflater.inflate(LayoutInflater.java:407)
08-23 17:13:58.899: ERROR/AndroidRuntime(9816):     at android.view.LayoutInflater.inflate(LayoutInflater.java:320)
08-23 17:13:58.899: ERROR/AndroidRuntime(9816):     at android.view.LayoutInflater.inflate(LayoutInflater.java:276)
08-23 17:13:58.899: ERROR/AndroidRuntime(9816):     at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:207)
08-23 17:13:58.899: ERROR/AndroidRuntime(9816):     at android.app.Activity.setContentView(Activity.java:1654)
08-23 17:13:58.899: ERROR/AndroidRuntime(9816):     at com.google.zxing.client.android.vofox.CaptureActivity.onCreate(CaptureActivity.java:157)
08-23 17:13:58.899: ERROR/AndroidRuntime(9816):     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1065)
08-23 17:13:58.899: ERROR/AndroidRuntime(9816):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2745)
08-23 17:13:58.899: ERROR/AndroidRuntime(9816):     ... 11 more
08-23 17:13:58.899: ERROR/AndroidRuntime(9816): Caused by: java.lang.ClassNotFoundException: com.google.zxing.client.android.ViewfinderView in loader dalvik.system.PathClassLoader[/data/app/com.google.zxing.client.android.vofox-1.apk]
08-23 17:13:58.899: ERROR/AndroidRuntime(9816):     at dalvik.system.PathClassLoader.findClass(PathClassLoader.java:243)
08-23 17:13:58.899: ERROR/AndroidRuntime(9816):     at java.lang.ClassLoader.loadClass(ClassLoader.java:573)
08-23 17:13:58.899: ERROR/AndroidRuntime(9816):     at java.lang.ClassLoader.loadClass(ClassLoader.java:532)
08-23 17:13:58.899: ERROR/AndroidRuntime(9816):     at android.view.LayoutInflater.createView(LayoutInflater.java:466)
08-23 17:13:58.899: ERROR/AndroidRuntime(9816):     at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:565)
08-23 17:13:58.899: ERROR/AndroidRuntime(9816):     ... 20 more
08-23 17:13:59.869: ERROR/libagl(103): uses alphaPlaneWorkaround
08-23 17:13:59.889: ERROR/libagl(103): uses alphaPlaneWorkaround
08-23 17:13:59.919: ERROR/libagl(103): uses alphaPlaneWorkaround
08-23 17:13:59.939: ERROR/libagl(103): uses alphaPlaneWorkaround

I created a project with the ZXing source code. That works fine.

After I changed the package name

 com.google.zxing.client.android 

to

 com.google.zxing.client.android.vofox

But it shows error in real device (HTC Wildfire)

It has no error in eclipse emulator. My logcat file shown below.

08-23 17:13:58.899: ERROR/AndroidRuntime(9816): FATAL EXCEPTION: main
08-23 17:13:58.899: ERROR/AndroidRuntime(9816): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.google.zxing.client.android.vofox/com.google.zxing.client.android.vofox.CaptureActivity}: android.view.InflateException: Binary XML file line #26: Error inflating class com.google.zxing.client.android.ViewfinderView
08-23 17:13:58.899: ERROR/AndroidRuntime(9816):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2781)
08-23 17:13:58.899: ERROR/AndroidRuntime(9816):     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2797)
08-23 17:13:58.899: ERROR/AndroidRuntime(9816):     at android.app.ActivityThread.access$2300(ActivityThread.java:135)
08-23 17:13:58.899: ERROR/AndroidRuntime(9816):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2132)
08-23 17:13:58.899: ERROR/AndroidRuntime(9816):     at android.os.Handler.dispatchMessage(Handler.java:99)
08-23 17:13:58.899: ERROR/AndroidRuntime(9816):     at android.os.Looper.loop(Looper.java:143)
08-23 17:13:58.899: ERROR/AndroidRuntime(9816):     at android.app.ActivityThread.main(ActivityThread.java:4914)
08-23 17:13:58.899: ERROR/AndroidRuntime(9816):     at java.lang.reflect.Method.invokeNative(Native Method)
08-23 17:13:58.899: ERROR/AndroidRuntime(9816):     at java.lang.reflect.Method.invoke(Method.java:521)
08-23 17:13:58.899: ERROR/AndroidRuntime(9816):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:858)
08-23 17:13:58.899: ERROR/AndroidRuntime(9816):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
08-23 17:13:58.899: ERROR/AndroidRuntime(9816):     at dalvik.system.NativeStart.main(Native Method)
08-23 17:13:58.899: ERROR/AndroidRuntime(9816): Caused by: android.view.InflateException: Binary XML file line #26: Error inflating class com.google.zxing.client.android.ViewfinderView
08-23 17:13:58.899: ERROR/AndroidRuntime(9816):     at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:576)
08-23 17:13:58.899: ERROR/AndroidRuntime(9816):     at android.view.LayoutInflater.rInflate(LayoutInflater.java:618)
08-23 17:13:58.899: ERROR/AndroidRuntime(9816):     at android.view.LayoutInflater.inflate(LayoutInflater.java:407)
08-23 17:13:58.899: ERROR/AndroidRuntime(9816):     at android.view.LayoutInflater.inflate(LayoutInflater.java:320)
08-23 17:13:58.899: ERROR/AndroidRuntime(9816):     at android.view.LayoutInflater.inflate(LayoutInflater.java:276)
08-23 17:13:58.899: ERROR/AndroidRuntime(9816):     at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:207)
08-23 17:13:58.899: ERROR/AndroidRuntime(9816):     at android.app.Activity.setContentView(Activity.java:1654)
08-23 17:13:58.899: ERROR/AndroidRuntime(9816):     at com.google.zxing.client.android.vofox.CaptureActivity.onCreate(CaptureActivity.java:157)
08-23 17:13:58.899: ERROR/AndroidRuntime(9816):     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1065)
08-23 17:13:58.899: ERROR/AndroidRuntime(9816):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2745)
08-23 17:13:58.899: ERROR/AndroidRuntime(9816):     ... 11 more
08-23 17:13:58.899: ERROR/AndroidRuntime(9816): Caused by: java.lang.ClassNotFoundException: com.google.zxing.client.android.ViewfinderView in loader dalvik.system.PathClassLoader[/data/app/com.google.zxing.client.android.vofox-1.apk]
08-23 17:13:58.899: ERROR/AndroidRuntime(9816):     at dalvik.system.PathClassLoader.findClass(PathClassLoader.java:243)
08-23 17:13:58.899: ERROR/AndroidRuntime(9816):     at java.lang.ClassLoader.loadClass(ClassLoader.java:573)
08-23 17:13:58.899: ERROR/AndroidRuntime(9816):     at java.lang.ClassLoader.loadClass(ClassLoader.java:532)
08-23 17:13:58.899: ERROR/AndroidRuntime(9816):     at android.view.LayoutInflater.createView(LayoutInflater.java:466)
08-23 17:13:58.899: ERROR/AndroidRuntime(9816):     at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:565)
08-23 17:13:58.899: ERROR/AndroidRuntime(9816):     ... 20 more
08-23 17:13:59.869: ERROR/libagl(103): uses alphaPlaneWorkaround
08-23 17:13:59.889: ERROR/libagl(103): uses alphaPlaneWorkaround
08-23 17:13:59.919: ERROR/libagl(103): uses alphaPlaneWorkaround
08-23 17:13:59.939: ERROR/libagl(103): uses alphaPlaneWorkaround

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

少女的英雄梦 2024-12-08 06:16:25

将 layouts/capture & 下的 com.google.zxing... 更改为 com.yourpackage 名称layouts-ldpi @ line

com.google.zxing.client.android.ViewfinderView

它解决了问题......它为我做了!

干杯!!

Change com.google.zxing.... to com.yourpackage name under layouts/capture & layouts-ldpi @ line

com.google.zxing.client.android.ViewfinderView

It solves the problem... It did for me!!!

Cheers!!

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文