我已将 zxing 库集成到我的应用程序中。尝试扫描 QR 码时出现运行时错误。它是由 NPE 在尝试从 XML 膨胀 ViewFinderView 对象时引起的。在我的项目中,我的所有应用程序代码都位于一个名为 com.carefreegroup 的包中,所有 zxing 代码都位于 com.google.zxing.client.android 中。我做了一些日志记录来测试 ViewFinderView 是否为空,它实际上返回为空。
谁能告诉我为什么这个物体没有膨胀,可能是包装问题吗?
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
如果需要检查包裹,我可以发布我的清单文件。
提前致谢