the49ltd / The49.Maui.BottomSheet

.NET MAUI library used to display pages as Bottom Sheets
MIT License
330 stars 31 forks source link

Java.Lang.NullPointerException: Attempt to invoke virtual method 'java.lang.Class java.lang.Object.getClass()' on a null object reference #88

Open ac-lap opened 10 months ago

ac-lap commented 10 months ago

I have a .net MAUI app published to Play Store, from the Microsoft Appcenter diagnostics I am seeing this exception resulting into crashes in production. I need help to understand why this could be happening and how to fix it. It has only the following stack trace for all crashes, no other events.

Java.Lang.NullPointerException: Attempt to invoke virtual method 'java.lang.Class java.lang.Object.getClass()' on a null object reference

Java.Interop.JniEnvironment.StaticMethods.CallStaticObjectMethod(JniObjectReference , JniMethodInfo , JniArgumentValue* )
Java.Interop.JniPeerMembers.JniStaticMethods.InvokeObjectMethod(String , JniArgumentValue* )
AndroidX.Core.View.WindowInsetsCompat.ToWindowInsetsCompat(WindowInsets )

The49.Maui.BottomSheet.BottomSheetController.get_WindowInsets()
The49.Maui.BottomSheet.BottomSheetController.get_Insets()
The49.Maui.BottomSheet.BottomSheetController.get_TopInset()
The49.Maui.BottomSheet.BottomSheetController.GetAvailableHeight()
The49.Maui.BottomSheet.BottomSheetController.ResizeVirtualView()
The49.Maui.BottomSheet.BottomSheetController.<>c__DisplayClass55_0.<Show>b__0()

Microsoft.Maui.Dispatching.Dispatcher.<>c__DisplayClass4_0.<DispatchImplementation>b__0()
Java.Lang.Thread.RunnableImplementor.Run()
Java.Lang.IRunnableInvoker.n_Run(IntPtr , IntPtr )
Android.Runtime.JNINativeWrapper.Wrap_JniMarshal_PP_V(_JniMarshal_PP_V , IntPtr , IntPtr )

java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.Class java.lang.Object.getClass()' on a null object reference
androidx.core.util.Preconditions.checkNotNull Preconditions.java:137
androidx.core.view.WindowInsetsCompat.toWindowInsetsCompat WindowInsetsCompat.java:168
androidx.core.view.WindowInsetsCompat.toWindowInsetsCompat WindowInsetsCompat.java:148
mono.java.lang.RunnableImplementor.n_run(Native Method)
mono.java.lang.RunnableImplementor.run RunnableImplementor.java:31
android.os.Handler.handleCallback Handler.java:938
android.os.Handler.dispatchMessage Handler.java:99
android.os.Looper.loop Looper.java:250
android.app.ActivityThread.main ActivityThread.java:7755
java.lang.reflect.Method.invoke(Native Method)
com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run RuntimeInit.java:592
com.android.internal.os.ZygoteInit.main ZygoteInit.java:958

I see this issue being hit by Android 10-13 users. Nuget version - 1.0.4

zafrkaya commented 10 months ago

This issue was occurring in my application when I pressed the back button to send the app to the background and then re-entered it (Nuget version - 1.0.4). After updating the NuGet package, I didn't experience the same problem again.

MarcAlx commented 10 months ago

Maybe related to this https://github.com/the49ltd/The49.Maui.BottomSheet/issues/63 (closed)