上的android ViewfinderView zxing captureActivity NPE [英] android zxing captureActivity NPE on ViewfinderView

查看:377
本文介绍了上的android ViewfinderView zxing captureActivity NPE的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经集成了zxing库到我的应用程序。我有一个运行时错误,当我尝试扫描QR code。它造成的试图夸大从XML ViewFinderView对象时,NPE。在我的项目我所有的应用程序的code位于包名为com.carefreegroup和所有的zxing code所在com.google.zxing.client.android。我做了一些记录来测试ViewFinderView是否为空,它事实上确实回来为空。

I've integrated the zxing library into my app. I have a runtime error when i try to scan a QR code. It's caused by a NPE when trying to inflate a ViewFinderView object from XML. In my project all my app's code resides in a package called com.carefreegroup and all the zxing code resides in com.google.zxing.client.android. I've done some logging to test whether the ViewFinderView is null and it does in fact come back as null.

谁能告诉我为什么这个对象没有被夸大,难道是包的问题?

Can anyone tell me why this object is not getting inflated, could it be a package problem?

01-02 15:09:53.887: E/AndroidRuntime(14732): FATAL EXCEPTION: main
01-02 15:09:53.887: E/AndroidRuntime(14732): java.lang.RuntimeException: Unable to resume activity {com.carefreegroup/com.google.zxing.client.android.CaptureActivity}: java.lang.NullPointerException
01-02 15:09:53.887: E/AndroidRuntime(14732):    at android.app.ActivityThread.performResumeActivity(ActivityThread.java:2850)
01-02 15:09:53.887: E/AndroidRuntime(14732):    at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:2889)
01-02 15:09:53.887: E/AndroidRuntime(14732):    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2265)
01-02 15:09:53.887: E/AndroidRuntime(14732):    at android.app.ActivityThread.access$600(ActivityThread.java:139)
01-02 15:09:53.887: E/AndroidRuntime(14732):    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1277)
01-02 15:09:53.887: E/AndroidRuntime(14732):    at android.os.Handler.dispatchMessage(Handler.java:99)
01-02 15:09:53.887: E/AndroidRuntime(14732):    at android.os.Looper.loop(Looper.java:156)
01-02 15:09:53.887: E/AndroidRuntime(14732):    at android.app.ActivityThread.main(ActivityThread.java:5045)
01-02 15:09:53.887: E/AndroidRuntime(14732):    at java.lang.reflect.Method.invokeNative(Native Method)
01-02 15:09:53.887: E/AndroidRuntime(14732):    at java.lang.reflect.Method.invoke(Method.java:511)
01-02 15:09:53.887: E/AndroidRuntime(14732):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
01-02 15:09:53.887: E/AndroidRuntime(14732):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
01-02 15:09:53.887: E/AndroidRuntime(14732):    at dalvik.system.NativeStart.main(Native Method)
01-02 15:09:53.887: E/AndroidRuntime(14732): Caused by: java.lang.NullPointerException
01-02 15:09:53.887: E/AndroidRuntime(14732):    at com.google.zxing.client.android.CaptureActivity.onResume(CaptureActivity.java:192)
01-02 15:09:53.887: E/AndroidRuntime(14732):    at android.app.Instrumentation.callActivityOnResume(Instrumentation.java:1236)
01-02 15:09:53.887: E/AndroidRuntime(14732):    at android.app.Activity.performResume(Activity.java:4625)
01-02 15:09:53.887: E/AndroidRuntime(14732):    at android.app.ActivityThread.performResumeActivity(ActivityThread.java:2834)
01-02 15:09:53.887: E/AndroidRuntime(14732):    ... 12 more

如果需要检查的包,我可以张贴我的清单文件。

I can post my manifest file if needed to check packages.

在此先感谢

推荐答案

您已经复制该项目的用户界面,包括 CaptureActivity ViewfinderView 。不这样做 - 这也不行,而不是完全允许的。你需要写你了解自己的应用程序和再利用的部分,为您了解一个应用程序。在这里,你的确粘贴一堆code不完全,当你做,这是行不通的。

You've copied the project's UI including CaptureActivity and ViewfinderView. Don't do that -- it's not OK and not wholly permitted. You need to write your own app and reuse parts that you understand, into an app that you understand. Here indeed you pasted a bunch of code incompletely, and it doesn't work when you do that.

按意图整合,或编写自己的应用程序。在任何情况下,请不要使用 com.google.zxing.client.android 是这样的。

Integrate by Intent, or write your own app. In any event please do not use com.google.zxing.client.android like this.

这篇关于上的android ViewfinderView zxing captureActivity NPE的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆