CameraController.ApplyCameraSettings System.NullReferenceException

HarshitaHarshita ✭✭✭✭INMember ✭✭✭✭

while opening zxing scanner page app crashed :

CameraController.ApplyCameraSettings
android.runtime.JavaProxyThrowable: System.NullReferenceException: Object reference not set to an instance of an object

Xamarin caused by: android.runtime.JavaProxyThrowable: System.NullReferenceException: Object reference not set to an instance of an object
ZXing.Mobile.CameraAccess.CameraController.ApplyCameraSettings()<57b37b10a314448c8d6b2b9155539100>:0
ZXing.Mobile.CameraAccess.CameraController.RefreshCamera()<57b37b10a314448c8d6b2b9155539100>:0
ZXing.Mobile.CameraAccess.CameraAnalyzer.RefreshCamera()<57b37b10a314448c8d6b2b9155539100>:0
ZXing.Mobile.ZXingSurfaceView.<SurfaceChanged>d__5.MoveNext()<57b37b10a314448c8d6b2b9155539100>:0
Android.App.SyncContext.<>c__DisplayClass2_0.<Post>b__0()<2307420e33a04321993781fdb887a40e>:0
Java.Lang.Thread.RunnableImplementor.Run()<2307420e33a04321993781fdb887a40e>:0
Java.Lang.IRunnableInvoker.n_Run(IntPtr jnienv, IntPtr native__this)<2307420e33a04321993781fdb887a40e>:0
at (wrapper dynamic-method) System.Object:b5211777-9dd6-4922-9884-a00186ce32e8 (intptr,intptr)
mono.java.lang.RunnableImplementor.n_run(Native Method)
mono.java.lang.RunnableImplementor.run()RunnableImplementor.java:30
android.os.Handler.handleCallback()Handler.java:739
android.os.Handler.dispatchMessage()Handler.java:95
android.os.Looper.loop()Looper.java:135
android.app.ActivityThread.main()ActivityThread.java:5276
java.lang.reflect.Method.invoke(Native Method)
java.lang.reflect.Method.invoke()Method.java:372
com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run()ZygoteInit.java:911
com.android.internal.os.ZygoteInit.main()ZygoteInit.java:706

how to solve this?

Answers

  • CharwakaCharwaka ✭✭✭✭✭ INMember ✭✭✭✭✭
    edited February 2018

    Did this happend while you rotating screen oreintation ?

    Have you tried adding Null Check for

    If(CameraAccess.CameraController!=null)
    {
    
    }
    
  • HarshitaHarshita ✭✭✭✭ INMember ✭✭✭✭

    @Charwaka
    No. I had not checked for Null :(

    I found this crash only one device,otherwise others devices scanning working fine.

  • CharwakaCharwaka ✭✭✭✭✭ INMember ✭✭✭✭✭

    @Harshita said:
    @Charwaka
    No. I had not checked for Null :(

    I found this crash only one device,otherwise others devices scanning working fine.

    Try adding Null Check where ever your sucspect

  • HarshitaHarshita ✭✭✭✭ INMember ✭✭✭✭

    @Charwaka
    CameraAccess.CameraController not found in backend code?

  • CharwakaCharwaka ✭✭✭✭✭ INMember ✭✭✭✭✭

    @Harshita said:
    @Charwaka
    CameraAccess.CameraController not found in backend code?

    can you message me your code i can check that.

  • HarshitaHarshita ✭✭✭✭ INMember ✭✭✭✭
    edited February 2018

    @Charwaka
    Here is my code:

    Scanner();
    
    public async void Scanner()
            {
                var ScannerPage = new ZXingScannerPage();
    
                ScannerPage.OnScanResult += (result) => {
    
                    ScannerPage.IsScanning = false;
                    Device.BeginInvokeOnMainThread(() => {
                        Navigation.PopAsync();
                        DisplayAlert("Code:", result.Text, "OK");
                        Asset.Text = result.Text;
                    });
                };
                await Navigation.PushAsync(ScannerPage);
            }
    
  • CharwakaCharwaka ✭✭✭✭✭ INMember ✭✭✭✭✭

    Hi @Harshita

    i think its a bug you can find the details here

    https://github.com/Redth/ZXing.Net.Mobile/issues/536

    so what you can do is manually build the Project from Src and add null checks or wait untill it gets fixed

    @JonathanDick can you help here ?

  • CharwakaCharwaka ✭✭✭✭✭ INMember ✭✭✭✭✭

    Hi @Harshita

    i think its a bug you can find the details here

    https://github.com/Redth/ZXing.Net.Mobile/issues/536

    so what you can do is manually build the Project from Src and add null checks or wait untill it gets fixed

    @JonathanDick can you help here ?

  • Alice_XamarinGuyAlice_XamarinGuy ✭✭ Member ✭✭

    Hi
    I'm also facing the same issue .

Sign In or Register to comment.