Zxing.net.mobile: Crash : CameraController.ApplyCameraSettings() - Object reference not set to an instance of an object

Created on 22 Sep 2017  路  8Comments  路  Source: Redth/ZXing.Net.Mobile

I am getting the following crash -

CameraController.ApplyCameraSettings() - Object reference not set to an instance of an object

Xamarin Forms - 2.3.4.270
ZXing.Net.Mobile version - 2.2.9
ZXing.Net.Mobile.Forms version - 2.2.9
Platform - Android
Device - Galaxy S5 mini
Android version - 6.0.1

Is this fix available in a existing pull request?

Most helpful comment

This issue still exists with ZXing.Net.Mobile.Forms 2.3.2 and Xamarin.Forms 2.5.0

All 8 comments

I see the same error in a plain Xamarin.Android app running on Android 6.0.

It looks like PR #635 attempts to fix this issue. Has anyone confirmed? Is there a planned NuGet package update?

Here's the stack trace of the NullReferenceException:

Xamarin caused by: android.runtime.JavaProxyThrowable: System.NullReferenceException: Object reference not set to an instance of an object at ZXing.Mobile.CameraAccess.CameraController.ApplyCameraSettings () [0x00007] in <7c7c485bd9034360a95deed1c4c824b8>:0 at ZXing.Mobile.CameraAccess.CameraController.RefreshCamera () [0x00010] in <7c7c485bd9034360a95deed1c4c824b8>:0 at ZXing.Mobile.CameraAccess.CameraAnalyzer.RefreshCamera () [0x00001] in <7c7c485bd9034360a95deed1c4c824b8>:0 at ZXing.Mobile.ZXingSurfaceView+<SurfaceChanged>d__4.MoveNext () [0x00073] in <7c7c485bd9034360a95deed1c4c824b8>:0 --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x0000c] in <59baef16a4a54e2b980400f9de7f8dda>:0 at System.Runtime.CompilerServices.AsyncMethodBuilderCore+<>c.<ThrowAsync>b__6_0 (System.Object state) [0x00000] in <59baef16a4a54e2b980400f9de7f8dda>:0 at Android.App.SyncContext+<>c__DisplayClass2_0.<Post>b__0 () [0x00000] in <1071b678fdc3476ebc8a909709a2ca76>:0 at Java.Lang.Thread+RunnableImplementor.Run () [0x00008] in <1071b678fdc3476ebc8a909709a2ca76>:0 at Java.Lang.IRunnableInvoker.n_Run (System.IntPtr jnienv, System.IntPtr native__this) [0x00008] in <1071b678fdc3476ebc8a909709a2ca76>:0 at (wrapper dynamic-method) System.Object:1fd094c9-d1b1-4388-8abe-eed9d86b4cf7 (intptr,intptr) at mono.java.lang.RunnableImplementor.n_run(Native Method) at mono.java.lang.RunnableImplementor.run(RunnableImplementor.java:30) at android.os.Handler.handleCallback(Handler.java:815) at android.os.Handler.dispatchMessage(Handler.java:104) at android.os.Looper.loop(Looper.java:207) at android.app.ActivityThread.main(ActivityThread.java:5765) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:789) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:679)

Same problem for me, I enter in a page where the camera is automatically opened from viewmodel, and this is my stacktrace:
CameraController.ApplyCameraSettings ()
System.NullReferenceException: Object reference not set to an instance of an object.
Object reference not set to an instance of an object.

CameraController.ApplyCameraSettings ()
CameraController.RefreshCamera ()
CameraAnalyzer.RefreshCamera ()
ZXingSurfaceView+d__5.MoveNext ()
ExceptionDispatchInfo.Throw ()
AsyncMethodBuilderCore+<>c.b__6_0 (System.Object state)
SyncContext+<>c__DisplayClass2_0.b__0 ()
Thread+RunnableImplementor.Run ()
IRunnableInvoker.n_Run (System.IntPtr jnienv, System.IntPtr native__this)
(wrapper dynamic-method) System.Object:923f32d9-c7b7-4ca4-bbf8-d70fd409785e (intptr,intptr)

I can not confirm that PR #635 fixes the Problem. I think the Camera.Open() is still failing if it gets called again. Do you also get the Message: Failed to Connect to Camera Service?

seeing the same issue, using an emulator of android 4.4, but only if the emulator has no camera's. I know I can't scan any barcodes without a camera, but I don't think it should throw an object reference error

This issue still exists with ZXing.Net.Mobile.Forms 2.3.2 and Xamarin.Forms 2.5.0

Still the same issue...

Same issue, Tried to use Ver 2.4.1 and I was getting reference errors that I could not fix. So I tried version 2.3.1 and had same issue on Android Tablet V 7.1, But when i tested on Android 6.0 the app worked Correctly. Using Latest Xamarin.Forms 3.2.0.87...

Thanks for reporting this issue! Unforunately it took me way too long to respond 馃槶. Sorry, I apologize! Recently the source code for this project was completely refactored to modernize it. Many PR's were included in this effort, and many bugs were hopefully fixed. Please try out the latest 3.x series of NuGet packages (currently in prerelease). To try and make the project more maintainable in my spare time going forward, I've decided to close all existing issues to start with a clean slate. If you're still experiencing this issue on the newest version, please open a new issue with as much detail as possible. Thank you for your patience and understanding! Happy scanning!

Was this page helpful?
0 / 5 - 0 ratings