Zxing.net.mobile: 2.2.9 cannot scan barcodes (QR is fine)

Created on 5 May 2017  路  22Comments  路  Source: Redth/ZXing.Net.Mobile

I recently added ZXing to my xamarin.iOS project as could successfully scan QR codes (default settings, no options provided). However, i was completely unable to scan any type of 1D barcodes (EAN8, EAN18). I downgraded to 2.1.47, and using the same code, i can now scan both QR and 1D barcodes.

I tried providing options for 2.2.9, allowing only 1D barcodes as PossibleFormats, but the only result of that was being unable to scan QR codes as well as 1D barcodes

Most helpful comment

Please fix this error as fast as possible.

All 22 comments

Ive updated to the latest nuget packages in all three projects (PCL, iOS and Droid) - 2.2.9 but only iOS is working.

Android is able to show the camera but the QR code is not getting detected whereby, the OnScanResult is never getting called.

Ive downgraded the packages and yet its still not scanning any QR code on Android.

Please, please can someone please help me?

Regards

I am using it in my Xamarin.Forms project and have similar issue.
The 1D barcodes do not scan at all in iOS. However, when I turn my phone to landscape mode, it scans.

Probably the iOS one is not processing 1D scans in portrait mode.
It seems to work fine on Android though.
@Redth It is a blocker and would be helpful if this can be resolved early. Thanks.

@hemantksh Any chance you can share your code? I would like to compare with what I've written? Im happy to share the code that I've got (its the same code on James's blog on the Xamarin website).

I tried both landscape and portrait but the code is not getting scanned. The android app shows the camera and I can the see QR code but nothing is happening.

Nothing fancy. Pretty straight. This is Xamarin.Forms.

`
var options = new ZXing.Mobile.MobileBarcodeScanningOptions();

        options.PossibleFormats = new List<ZXing.BarcodeFormat>() {
            ZXing.BarcodeFormat.CODE_39,
            ZXing.BarcodeFormat.CODE_93,
            ZXing.BarcodeFormat.CODE_128,
            ZXing.BarcodeFormat.EAN_13,
            ZXing.BarcodeFormat.QR_CODE
        };

        zxing = new ZXingScannerView
        {
            HorizontalOptions = LayoutOptions.FillAndExpand,
            VerticalOptions = LayoutOptions.FillAndExpand,
            Options = options
        };

        zxing.OnScanResult += (result) =>
        {
            Device.BeginInvokeOnMainThread(async () =>
            {
                zxing.IsAnalyzing = false;  // stop analysis
                g.LastScanResult = result;
                await Navigation.PopAsync(animated: false);  // close view
            });
        };

`

I noticed if I use the same code from FragmentActivity (in the sample code), the camera works nice but no QR Code detected (or other code formats).

If I use the sample code for using it with Activity, it works great. It seems it doesn't recognize anything when I use a Fragment / FragmentActivity.

  • Native project (Xamarin.iOS / Xamarin.Droid)
  • Nuget package version : 2.2.9
  • Android API level 18 (not tested above)
  • iOS : not tested yet

I've got the same problem.
Everything works fine on Android but there are some problems on iOS.
The iOS varient only recognises linear codes in landscape mode.
Someone found a workaround or a solution for this?

Please fix this error as fast as possible.

@hemantksh Any chance you can share your code?

@hareshkainth why didn麓t you share your code in the first place. That would simply help out

@hemantksh and @ahmedalejo Sorry all, I got busy looking at the source code and was trying to figure out how to fix the issue.

Below is my code, note, it works on iOS but on Android it doesn't scan anything.

var scanPage = new ZXingScannerPage();
var options = new MobileBarcodeScanningOptions
{
AutoRotate = false,
UseFrontCameraIfAvailable = false,
TryHarder = true,
PossibleFormats = new List
{
ZXing.BarcodeFormat.QR_CODE
}
};

scanPage = new ZXingScannerPage(options)
{
DefaultOverlayTopText = "Align code within the frame",
DefaultOverlayBottomText = string.Empty,
DefaultOverlayShowFlashButton = true
};

scanPage.OnScanResult += (result) =>
{
// Stop scanning
scanPage.IsScanning = false;

// Pop the page and show the result
Device.BeginInvokeOnMainThread(() =>

{
// Do something.
};
};

I downgraded to 2.1.47 because of this bug, but it seems that 1D barcodes still take an awfully long time to be detected, if at all. That's on my cheap Android device, I've not checked iOS yet.

Any chance of a comment from the author? Perhaps there's a functionality change that isn't documented yet?

Hello, same problem, IOS does not analyzing in portrait mode, when I rotate 1D code vertically it get read. Pls help.

@pdonovan The long time problem should be affected by the device. version 2.1.47 works fine for me. The author seems that does not review the issues on this project.

Its working in Landscape mode not portrait(iOS). how to fix it in Portrait mode?

Not working here either in portrait mode ... have downgraded to 2.1.47, which is working :-(

same story here 2.1.47 is the solution for now

wrote a direct message to @Redth twitter (@redth), hope that he fix this issue asap

I've downgraded the plugin to version 2.1.47 for Android and I can confirm that my Android app can scan QR codes again.

Hi,

I downgraded to 2.1.47 and portrait mode is working. @kentfonager Thanks man its working fine and my customOverlay not displaying. How to fix it ?

@shanmugasundharamselvadurai

The binding context of the ZXingDefaultOverlay view was never set, so you will not see any your UI changes on it...

current solution of problem for me now is declaring ZXingDefaultOverlay in behind code (or in viewmodel) and then we need to set BindingContext for the declared ZXingDefaultOverlay to itself

Hi,

Seems like I have similar problems.
iOS 11, iPhone 7. Can scan QR-codes with no problems. But ean13 I only can scan if the code is vertical - not horizontal like I want! Look at images. Why why why??

vertical-works
horizontal not working

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