locked
Why is ZXing.Net.Mobile crashing after camera permission? RRS feed

  • Question

  • User270740 posted

    Hi all, I am working xamarin.forms app and i use ZXing.Net.Mobile to read QR Code. Application is working greate but although i grante camera permission, it is crashing. When i open application again it is working fine.

    Could you tell me reason please?

    Best regards

    Wednesday, May 31, 2017 6:59 AM

All replies

  • User248173 posted

    @ccaner

    i am also getting same issue........! if you got solution please share here.

    Thank You

    Thursday, June 15, 2017 1:36 PM
  • User270740 posted

    Hi @"Vaka.GopiNadhReddy"

    I would help you but i have not found any solution yet. I am gonne work on it so soon. If you find solution, can you tell us ?

    Best Regards

    Thursday, June 15, 2017 1:43 PM
  • User314320 posted

    I had a similar issue, but only on Android. After permission accepted, the app would crash. After restart, it worked fine. Only crashes very first time. I then noticed in the MainActivity.cs a warning about a deprecated method:

        public override void OnRequestPermissionsResult(int requestCode, string[] permissions, Permission[] grantResults)
        {
            global::ZXing.Net.Mobile.Forms.Android.PermissionsHandler.OnRequestPermissionsResult(requestCode, permissions, grantResults);
        }
    

    changed to below and problem went away:

            global::ZXing.Net.Mobile.Android.PermissionsHandler.OnRequestPermissionsResult(requestCode, permissions, grantResults);
    

    notice the removal of .Forms from before .Android...

    Anyway, that worked for me.

    Saturday, August 19, 2017 5:30 AM
  • User270740 posted

    Hi all,

    Ok when i try it, i will tell u result. Thank u for your help.

    Best Regards

    Monday, August 21, 2017 6:42 AM
  • User189436 posted

    @TonySpencer said: I had a similar issue, but only on Android. After permission accepted, the app would crash. After restart, it worked fine. Only crashes very first time. I then noticed in the MainActivity.cs a warning about a deprecated method:

        public override void OnRequestPermissionsResult(int requestCode, string[] permissions, Permission[] grantResults)
        {
            global::ZXing.Net.Mobile.Forms.Android.PermissionsHandler.OnRequestPermissionsResult(requestCode, permissions, grantResults);
        }
    

    changed to below and problem went away:

            global::ZXing.Net.Mobile.Android.PermissionsHandler.OnRequestPermissionsResult(requestCode, permissions, grantResults);
    

    notice the removal of .Forms from before .Android...

    Anyway, that worked for me.

    This worked for me, after two days I was getting crazy!

    Thanks!

    Wednesday, September 27, 2017 3:18 PM
  • User189436 posted

    It's me again,

    @TonySpencer solution worked for me, but I have noticed that the first time that you open the scan page after ask for permission It doesn't scan or is very difficult. If you return to the previous page and then go again to scan it works perfect. At least that happen to me in the phones that I have try!

    Regards

    Wednesday, September 27, 2017 3:50 PM
  • User111573 posted

    Hi @rxama did you find any solution for the above thread.I am also facing same problem the qr code wont works after giving permissions.

    Monday, April 30, 2018 3:20 PM
  • User368282 posted

    Hello,

    I have changed the deprecated version to: global::ZXing.Net.Mobile.Android but now get an error (red squiggly) from global:: to Android. What am i doing wrong? is this just a reference issue?

    Monday, May 14, 2018 3:50 AM
  • User243845 posted

    @rxama and @manoharbonala - I, too, am seeing that after granting camera permissions on Android devices, the first scan does not work. If I tap "Back" and then rescan, scanning works fine. All subsequent scans work. It is only he first scan after granting permissions that does not work. I do not see this on the iOS devices that I am testing. Have you found a solution to this problem?

    EDIT: See the thread below. Reverting to ZXing.Net.Mobile 2.3.2 and ZXing.Net.Mobile.Forms 2.3.2 fixed the problem for me.

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

    Thursday, October 18, 2018 11:03 AM
  • User360155 posted

    @TonySpencer said: I had a similar issue, but only on Android. After permission accepted, the app would crash. After restart, it worked fine. Only crashes very first time. I then noticed in the MainActivity.cs a warning about a deprecated method:

        public override void OnRequestPermissionsResult(int requestCode, string[] permissions, Permission[] grantResults)
        {
            global::ZXing.Net.Mobile.Forms.Android.PermissionsHandler.OnRequestPermissionsResult(requestCode, permissions, grantResults);
        }
    

    changed to below and problem went away:

            global::ZXing.Net.Mobile.Android.PermissionsHandler.OnRequestPermissionsResult(requestCode, permissions, grantResults);
    

    notice the removal of .Forms from before .Android...

    Anyway, that worked for me.

    In 2020 the solution is this one.. Please update the documentation, I spent 3 days to find this! @JonathanDick

    Friday, November 6, 2020 7:31 AM
  • User398246 posted

    It depends by a zxing bug (may be different by the release). Add a delay after grant setting only for the first time, before to open the scanner page.

    You can do something like this:

    if ( ! checkPermission(...)) // execute your check method for "not" camera grants { await setpermission(...); // execute your method to set the grants await Task.Delay(500); // wait for 500 ms, it may be enough } // now you can navigate to the scanner page if the user confirms the grants if (checkPermission(...)) // execute your check method for the camera grants { ... // do work } In this case you have a delay only for the first time, when the user confirms the grants.

    This is only a patch, not a perfect solution.

    Wednesday, December 2, 2020 9:29 AM
  • User394400 posted

    Hello, I had the same problem, and after a lot of research I found the TonySpencer solution. It works perfectly well: a big thank you to him !

    Friday, March 19, 2021 6:47 PM