Hi all,
I am using latest Xamarin.Forms to scan a QR-Code with ZXing barcode scanner.
On iOS everything is working fine, but on android my app is crashing.
I can start the barcodscanner and the camara will show me a live picture for may be 1 or 2 seconds, then my app is crashing without showing an exception in Visual Studio.
From logcat I copied the following exception:
03-31 19:47:50.682 E/mono (16172): Unhandled Exception:
03-31 19:47:50.682 E/mono (16172): System.ArgumentException: 'jobject' must not be IntPtr.Zero.
03-31 19:47:50.682 E/mono (16172): Parameter name: jobject
03-31 19:47:50.682 E/mono (16172): at Android.Runtime.JNIEnv.CallVoidMethod (IntPtr jobject, IntPtr jmethod, Android.Runtime.JValue[] parms) [0x00000] in :0
03-31 19:47:50.682 E/mono (16172): at Android.Widget.AdapterView.set_OnItemClickListener (IOnItemClickListener value) [0x00000] in :0
03-31 19:47:50.682 E/mono (16172): at Xamarin.Forms.Platform.Android.ListViewAdapter.Dispose (Boolean disposing) [0x00000] in :0
03-31 19:47:50.682 E/mono (16172): at Java.Lang.Object.Finalize () [0x00000] in :0
I am using the folowing code to call the scanner:
public async Task<BarcodeScanResult> Scan()
{
ZXing.Mobile.MobileBarcodeScanner scanner = new ZXing.Mobile.MobileBarcodeScanner(global::Xamarin.Forms.Forms.Context);
scanner.UseCustomOverlay = false;
MobileBarcodeScanningOptions scanOptions = new MobileBarcodeScanningOptions();
scanOptions.PossibleFormats.Add(ZXing.BarcodeFormat.QR_CODE);
ZXing.Result result = await scanner.Scan(scanOptions);
if (result == null)
{
return null;
}
return new BarcodeScanResult { Text = result.Text };
}