im getting an Error in my Xamarin Forms Application. This error only occurs on Android. iOS Works fine.
This is the line where the Exception is thrown.
ZXing.Net.Mobile.Forms.Android.Platform.Init();
This is the Exception
Could not load typeZXing.Net.Mobile.Forms.Android.ZXingScannerViewRenderer'
from assembly 'ZXing.Net.Mobile.Forms.Android, Version=2.1.47.0,
Culture=neutral, PublicKeyToken=null'.
StackTrance:
at ZXing.Net.Mobile.Forms.Android.Platform.Init () [0x00000] in <30849edafd8e4fbb9f24af588a9bebb0>:0
at AllergyDetector.Droid.MainActivity.OnCreate (Android.OS.Bundle bundle) [0x0002d] in /Users/alexanderrummel/Development/Projects/dotNet/AllergyDetector/Droid/MainActivity.cs:28
at Android.Support.V4.App.FragmentActivity.n_OnCreate_Landroid_os_Bundle_ (System.IntPtr jnienv, System.IntPtr native__this, System.IntPtr native_savedInstanceState) [0x00011] in <27c17fe440cf491ba8255bcefade6e02>:0
at (wrapper dynamic-method) System.Object:ceddf78a-cf9a-4fee-97a9-ea86e17b2375 (intptr,intptr,intptr)
I use the following Versions
XamarinForms: 2.3.3.152-pre2
ZXing.Net.Mobile 2.1.47
ZXing.Net.Mobile.Forms 2.1.47
TargetFramework Android 5.0
MinimalAndroid Version Android 5.0
After a quick Google action it seems that this is a known issue with the Xamarin.Forms 2.3.3.152-pre2 release. Have a look at the GitHub page here although it also seems to happen with other version of Xamarin.Forms.
There also is a fix suggested by richardpike:
I was able to fix this for myself by downloading the source code and updating the xamarin forms package to the pre-release (2.3.3.152-pre2)
This required 2 new override functions in ZXingScannerViewRenderer.cs, and ZXingBarcodeImageViewRenderer.cs (from the ZXing.Net.Mobile.Forms.Android project). All I did was make them return null.
This builds successfully and I was able to use the resulting dll in my project without it crashing.
I would make a pull request, but I've never done one before using github...
If that is not something you're comfortable with I'm afraid you are stuck with waiting until they have fixed this.