Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ZXingBarcodeImageView not working correctly after updating to Xamarin.Forms 2.3.3.193 #507

Closed
declandowling opened this issue Mar 8, 2017 · 3 comments

Comments

@declandowling
Copy link

We recently attempted to upgrade our Xamarin.Forms version from 2.3.2.127 to 2.3.3.193. In doing so, the ZXingBarcodeImageView started to misbehave. Our current release is using Xamarin.Forms 2.3.2.127 and is working fine, when attempting to upgrade to Xamarin.Forms 2.3.3.193 we noticed an issue/crash with rendering barcodes.

Here is my XAML
<forms:ZXingBarcodeImageView HorizontalOptions="FillAndExpand" VerticalOptions="FillAndExpand" BarcodeFormat="EAN_13" x:Name="BarcodeImageView" BarcodeValue="{Binding Barcode}" BarcodeOptions="{Binding BarcodeOptions}" />

We have encountered two different errors from ZXings captured via the google play developer console.

Error #1:
java.lang.RuntimeException: java.lang.reflect.InvocationTargetException at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1120) Caused by: java.lang.reflect.InvocationTargetException at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1230) ... 1 more Caused by: android.runtime.JavaProxyThrowable: System.ObjectDisposedException: Cannot access a disposed object. Object name: 'Android.Widget.ImageView'. at Java.Interop.JniPeerMembers.AssertSelf (Java.Interop.IJavaPeerable self) [0x00030] in <ab2cb73a159d4dd0885e26f8d9501328>:0 at Java.Interop.JniPeerMembers+JniInstanceMethods.InvokeVirtualVoidMethod (System.String encodedMember, Java.Interop.IJavaPeerable self, Java.Interop.JniArgumentValue* parameters) [0x00001] in <ab2cb73a159d4dd0885e26f8d9501328>:0 at Android.Widget.ImageView.SetImageBitmap (Android.Graphics.Bitmap bm) [0x00036] in <2bf0406cbd0d4a84bcccace1f02d2e19>:0 at ZXing.Net.Mobile.Forms.Android.ZXingBarcodeImageViewRenderer+<>c__DisplayClass5_0.<regenerate>b__0 () [0x00012] in <30849edafd8e4fbb9f24af588a9bebb0>:0 at Java.Lang.Thread+RunnableImplementor.Run () [0x0000b] in <2bf0406cbd0d4a84bcccace1f02d2e19>:0 at Java.Lang.IRunnableInvoker.n_Run (System.IntPtr jnienv, System.IntPtr native__this) [0x00009] in <2bf0406cbd0d4a84bcccace1f02d2e19>:0 at (wrapper dynamic-method) System.Object:5af8b346-78fc-4e55-a08a-71f9a04d8b87 (intptr,intptr) at mono.java.lang.RunnableImplementor.n_run(Native Method) at mono.java.lang.RunnableImplementor.run(RunnableImplementor.java:30) at android.os.Handler.handleCallback(Handler.java:739) at android.os.Handler.dispatchMessage(Handler.java:95) at android.os.Looper.loop(Looper.java:158) at android.app.ActivityThread.main(ActivityThread.java:7224) ... 3 more

Error #2:
java.lang.RuntimeException: java.lang.reflect.InvocationTargetException at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1120) Caused by: java.lang.reflect.InvocationTargetException at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1230) ... 1 more Caused by: android.runtime.JavaProxyThrowable: System.ArgumentException: Contents do not pass checksum at ZXing.OneD.EAN13Writer.encode (System.String contents) [0x00094] in <09b1b057ede04f4891d9ca3d84f4fe6d>:0 at ZXing.OneD.OneDimensionalCodeWriter.encode (System.String contents, ZXing.BarcodeFormat format, System.Int32 width, System.Int32 height, System.Collections.Generic.IDictionary``2[TKey,TValue] hints) [0x00094] in <09b1b057ede04f4891d9ca3d84f4fe6d>:0 at ZXing.OneD.EAN13Writer.encode (System.String contents, ZXing.BarcodeFormat format, System.Int32 width, System.Int32 height, System.Collections.Generic.IDictionary``2[TKey,TValue] hints) [0x0001e] in <09b1b057ede04f4891d9ca3d84f4fe6d>:0 at ZXing.MultiFormatWriter.encode (System.String contents, ZXing.BarcodeFormat format, System.Int32 width, System.Int32 height, System.Collections.Generic.IDictionary``2[TKey,TValue] hints) [0x00033] in <09b1b057ede04f4891d9ca3d84f4fe6d>:0 at ZXing.BarcodeWriterGeneric``1[TOutput].Encode (System.String contents) [0x0002f] in <09b1b057ede04f4891d9ca3d84f4fe6d>:0 at ZXing.BarcodeWriterGeneric``1[TOutput].Write (System.String contents) [0x00013] in <09b1b057ede04f4891d9ca3d84f4fe6d>:0 at ZXing.Net.Mobile.Forms.Android.ZXingBarcodeImageViewRenderer+<>c__DisplayClass5_0.<regenerate>b__0 () [0x00000] in <30849edafd8e4fbb9f24af588a9bebb0>:0 at Java.Lang.Thread+RunnableImplementor.Run () [0x0000b] in <2bf0406cbd0d4a84bcccace1f02d2e19>:0 at Java.Lang.IRunnableInvoker.n_Run (System.IntPtr jnienv, System.IntPtr native__this) [0x00009] in <2bf0406cbd0d4a84bcccace1f02d2e19>:0 at (wrapper dynamic-method) System.Object:58271858-a9fe-4648-9eb6-dca4baf6dd14 (intptr,intptr) at mono.java.lang.RunnableImplementor.n_run(Native Method) at mono.java.lang.RunnableImplementor.run(RunnableImplementor.java:30) at android.os.Handler.handleCallback(Handler.java:739) at android.os.Handler.dispatchMessage(Handler.java:95) at android.os.Looper.loop(Looper.java:158) at android.app.ActivityThread.main(ActivityThread.java:7224) ... 3 more

Has anybody else encountered a similar issue when upgrading Xamarin.Forms? Any help will be greatly appreciated.

P.s. is this library still maintained? There are a lot of open issues and no commits since November. If this library is stale, can anybody suggest an alternative?

@codingL3gend
Copy link

@declandowling i had this same issue found this post during some googling that said add this to your info.plist and it worked for me

NSCameraUsageDescription
Can we use your camera

@RedTahr
Copy link

RedTahr commented Mar 15, 2017

@declandowling i've been getting your error #1, still looking for a workaround...
ammendment:
for me I stopped the view in question from rerunning OnAppearing if it had already run (such as when returning to a Xamarin.Forms view after using ZXing to scan a QR code, or when returning to the view from an NFC fired intent), which stopped the imageview exception...so far...

@Redth
Copy link
Owner

Redth commented Mar 13, 2020

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!

@Redth Redth closed this as completed Mar 13, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants