Xamarin Barcode Scanner

I am trying to do a barcode scanner in Xamarin using ZXing based on this page: github.com/Redth/ZXing.Net.Mobile

Unfortunately, the only thing I get is an exception. The code compiles nicely, there are no errors or warnings, I start the application on Samsung S7 and I get an error

        Unhandled Exception:
        System.Reflection.TargetInvocationException: <Timeout exceeded getting exception details>

Sometimes it shows:

[...] index was outside the bounds of the array [..]

I've been fighting this since yesterday and I have no idea what might be wrong, the videos are working and in my case I have no chance :(

I use vs 2017 Community and packages:

  • ZXing.Net.Mobile.Forms - 2.4.1
  • ZXing.Net.Mobile - 2.4.1
  • Xamarin.Forms -

My project to download if someone would like to see the whole code: cyrklaf.eu/skaner.rar

I'm missing ideas, like a simple thing, and the problems themselves

Best Answer


  • ClintStLaurentClintStLaurent USUniversity ✭✭✭✭✭

    Turn on 'break for exception' for the IndexOutOfBounds so you can see where that is happening.

  • reverse1987reverse1987 Member ✭✭
    edited September 2018

    It's my actual code:
    Now when i click Skanuj nothing happens at all :(

  • AlessandroCaliaroAlessandroCaliaro ITMember ✭✭✭✭✭
  • reverse1987reverse1987 Member ✭✭
    I tried. the application starts without errors but when I clicked on the button, nothing happened.
  • AlessandroCaliaroAlessandroCaliaro ITMember ✭✭✭✭✭
    It works for me on some devices. Maybe a Samsung problem. Can you use other devices for your tests?
  • reverse1987reverse1987 Member ✭✭

    Hello :)
    I will check today on another phone, because on my if I click Scan, nothing happens. And you can do something to make it work on all Android devices, not on some devices? if instead of this code:

      scanPage = new ZXingScannerPage ();
                 scanPage.OnScanResult + = (result) =>
                     scanPage.IsScanning = false;
                     Device.BeginInvokeOnMainThread (() =>
                         Navigation.PopAsync ();
                         DisplayAlert ("Scanned Barcode", result.Text, "OK");
                 await Navigation.PushAsync (scanPage);

    how I give eg DialogAlert this click works without a problem: D tested my code at home?

  • AlessandroCaliaroAlessandroCaliaro ITMember ✭✭✭✭✭

    I think it's a ZXing nuget problem… have you tried to open an issue on github?

  • reverse1987reverse1987 Member ✭✭

    I just wrote https://github.com/zxing/zxing/issues/1065 but they closed my thread. Can the problem lie in the fact that I am launching the application via Xamarin Live?

  • ClintStLaurentClintStLaurent USUniversity ✭✭✭✭✭

    Can the problem lie in the fact that I am launching the application via Xamarin Live?

    SHouldn't be. But you can test that theory easily enough can't you? Launch it in another way. Just deploy it to a device from Visual Studio and see if it behaves in the same way.

  • reverse1987reverse1987 Member ✭✭
    edited September 2018

    When i deploy TestZxing apk to phone i have white screen. Permission for camera is enable

  • AlessandroCaliaroAlessandroCaliaro ITMember ✭✭✭✭✭
    Maybe a permission problem? Which is the Os version ? I don’t remember if that’s demo has runtime permission...
  • reverse1987reverse1987 Member ✭✭

    The problem was in ZXing.Net.Mobile.Forms - 2.4.1 when I changed the version to 2.3.2 it all started working. Thank you for your help :)

Sign In or Register to comment.