Redth / ZXing.Net.Maui

Barcode Scanning for MAUI?
MIT License
460 stars 151 forks source link

Java.Lang.IllegalArgumentException: 'Trying to create LifecycleCamera with destroyed lifecycle.' #176

Open JRosanowski opened 6 months ago

JRosanowski commented 6 months ago

We're using the library, .Net 8 Maui and Native embedding as described here. https://learn.microsoft.com/en-us/dotnet/maui/platform-integration/native-embedding?view=net-maui-8.0&pivots=devices-android When the view is displayed we get this exception. Java.Lang.IllegalArgumentException: 'Trying to create LifecycleCamera with destroyed lifecycle.'

It was working ok with .Net 7 but we were also using the previous method of embedding. The embedding method seems to be have been updated by the Maui team for .Net 8. So we're not sure if this is some problem with the way Maui Native embedding is done now or some issue with the library which means it doesn't work in .Net 8.

0xFFFFFFFFFFFFFFFF in Android.Runtime.RuntimeNativeMethods.monodroid_debugger_unhandled_exception 0x1A in Android.Runtime.JNINativeWrapper._unhandled_exception at /Users/runner/work/1/s/xamarin-android/src/Mono.Android/Android.Runtime/JNINativeWrapper.g.cs:13,5 0x1D in Android.Runtime.JNINativeWrapper.Wrap_JniMarshal_PP_V at /Users/runner/work/1/s/xamarin-android/src/Mono.Android/Android.Runtime/JNINativeWrapper.g.cs:27,26 0x17 in System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw 0x6D in Java.Interop.JniEnvironment.InstanceMethods.CallObjectMethod at /Users/runner/work/1/s/xamarin-android/external/Java.Interop/src/Java.Interop/obj/Release/net7.0/JniEnvironment.g.cs:19992,5 0x26 in Java.Interop.JniPeerMembers.JniInstanceMethods.InvokeAbstractObjectMethod at /Users/runner/work/1/s/xamarin-android/external/Java.Interop/src/Java.Interop/Java.Interop/JniPeerMembers.JniInstanceMethods_Invoke.cs:848,6 0x7C in AndroidX.Camera.Lifecycle.ProcessCameraProvider.BindToLifecycle at /Users/runner/work/1/s/generated/androidx.camera.camera-lifecycle/obj/Release/net6.0-android/generated/src/AndroidX.Camera.Lifecycle.ProcessCameraProvider.cs:63,5 0xBA in ZXing.Net.Maui.CameraManager.UpdateCamera 0xC4 in ZXing.Net.Maui.CameraManager. 0x6 in Java.Lang.Runnable.Run at /Users/runner/work/1/s/xamarin-android/src/Mono.Android/Java.Lang/Runnable.cs:27,4 0x8 in Java.Lang.IRunnableInvoker.n_Run at /Users/runner/work/1/s/xamarin-android/src/Mono.Android/obj/Release/net8.0/android-34/mcw/Java.Lang.IRunnable.cs:84,4 0x8 in Android.Runtime.JNINativeWrapper.Wrap_JniMarshal_PP_V at /Users/runner/work/1/s/xamarin-android/src/Mono.Android/Android.Runtime/JNINativeWrapper.g.cs:26,5