Search code examples
xamarin.formszxing

ZXing crash in MaterDetailPage


I have a Xamarin Forms project with a lateral menu using the MasterDetailPage. In iOS all works OK, but in Android the app crash when I push the ZXingScanner. However, when I use it from a 'Main Page' works ok too.

ZXingScannerPage pagina = new ZXingScannerPage();

pagina.OnScanResult += (result) => 
{ 
    try { 
         pagina.IsScanning = false; 

         Device.BeginInvokeOnMainThread(async() => 
         { 

           var code = result.Text; 
           await App.Current.MainPage.Navigation.PopModalAsync();

           await App.Current.MainPage.DisplayAlert("Scanned", code, "OK); 



         }); 
      } catch (Exception ex) {
        Debug.WriteLine("Error " + ex.Message); 
      } 
};


await App.Current.MainPage.Navigation.PushAsync(pagina);

Is there any way to fix this?


Solution

  • The same issue happened to me. Please check this link. Make sure that there are no unwanted NuGet packages installed in your solution. Also make sure that you are using the stable version of packages. If the issue is persisting even after this, I suggest you to create the same project from the scratch. It solved my issue.