Android: ListView can crash
hansemannn opened this issue · 5 comments
We are receiving the following crash on a regular base:
Exception java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.String java.lang.Object.toString()' on a null object reference
at android.widget.ArrayAdapter.createViewFromResource (ArrayAdapter.java:454)
at android.widget.ArrayAdapter.getView (ArrayAdapter.java:416)
at android.widget.AbsListView.obtainView (AbsListView.java:2440)
at android.widget.ListView.measureHeightOfChildren (ListView.java:1417)
at android.widget.ListView.onMeasure (ListView.java:1323)
at android.view.View.measure (View.java:25977)
at android.view.ViewGroup.measureChildWithMargins (ViewGroup.java:7073)
at android.widget.FrameLayout.onMeasure (FrameLayout.java:194)
at android.view.View.measure (View.java:25977)
at androidx.appcompat.widget.AlertDialogLayout.tryOnMeasure (AlertDialogLayout.java:134)
at androidx.appcompat.widget.AlertDialogLayout.onMeasure (AlertDialogLayout.java:64)
at android.view.View.measure (View.java:25977)
at android.view.ViewGroup.measureChildWithMargins (ViewGroup.java:7073)
at android.widget.FrameLayout.onMeasure (FrameLayout.java:194)
at androidx.appcompat.widget.ContentFrameLayout.onMeasure (ContentFrameLayout.java:145)
at android.view.View.measure (View.java:25977)
at android.view.ViewGroup.measureChildWithMargins (ViewGroup.java:7073)
at android.widget.FrameLayout.onMeasure (FrameLayout.java:194)
at android.view.View.measure (View.java:25977)
at android.view.ViewGroup.measureChildWithMargins (ViewGroup.java:7073)
at android.widget.FrameLayout.onMeasure (FrameLayout.java:194)
at android.view.View.measure (View.java:25977)
at android.view.ViewGroup.measureChildWithMargins (ViewGroup.java:7073)
at android.widget.LinearLayout.measureChildBeforeLayout (LinearLayout.java:1552)
at android.widget.LinearLayout.measureVertical (LinearLayout.java:842)
at android.widget.LinearLayout.onMeasure (LinearLayout.java:721)
at android.view.View.measure (View.java:25977)
at android.view.ViewGroup.measureChildWithMargins (ViewGroup.java:7073)
at android.widget.FrameLayout.onMeasure (FrameLayout.java:194)
at com.android.internal.policy.DecorView.onMeasure (DecorView.java:832)
at android.view.View.measure (View.java:25977)
at android.view.ViewRootImpl.performMeasure (ViewRootImpl.java:3805)
at android.view.ViewRootImpl.measureHierarchy (ViewRootImpl.java:2539)
at android.view.ViewRootImpl.performTraversals (ViewRootImpl.java:2836)
at android.view.ViewRootImpl.doTraversal (ViewRootImpl.java:2278)
at android.view.ViewRootImpl$TraversalRunnable.run (ViewRootImpl.java:9034)
at android.view.Choreographer$CallbackRecord.run (Choreographer.java:1227)
at android.view.Choreographer.doCallbacks (Choreographer.java:1024)
at android.view.Choreographer.doFrame (Choreographer.java:934)
at android.view.Choreographer$FrameDisplayEventReceiver.run (Choreographer.java:1212)
at android.os.Handler.handleCallback (Handler.java:938)
at android.os.Handler.dispatchMessage (Handler.java:99)
at android.os.Looper.loopOnce (Looper.java:233)
at android.os.Looper.loop (Looper.java:344)
at android.app.ActivityThread.main (ActivityThread.java:8191)
at java.lang.reflect.Method.invoke
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run (RuntimeInit.java:584)
at com.android.internal.os.ZygoteInit.main (ZygoteInit.java:1034)
Stackoverlow suggests that it's an uninitialized array issue.
Expected Behavior
The app does not crash.
Actual behavior
The app crashes.
Reproducible sample
Unfortunately, I haven't received any link to our source files, making it hard to find right now.
Steps to reproduce
n/a
Platform
Android
SDK version you are using
11.1.1
Alloy version you are using
No response
this might also help: dotnet/maui#8377
same last error line ArrayAdapter.java:454
and the stack files look almost identically too. In their case the picker is the issue even though its not visible in the logs
Places to add null checks:
https://github.com/tidev/titanium_mobile/blob/f80e1dc35b7e1d8795fd096db2b350fddc94e88c/android/modules/ui/src/java/ti/modules/titanium/ui/widget/listview/ListSectionProxy.java#L57
(there a more this.items.add(item);
in that file)
can you Assign me this Issue
@venkat-clone Sure - happy to see you on board! @m1ga I am not sure if that solves it, because it kind of looks like an activity-related issue, when measureChildWithMargins
is called so many times.
The measureChildWithMargins
errors are in the MAUI log too. That PR is here dotnet/maui#8407
Just saying that it could be in a different place and not in the ListView or the add(item)
parts. But maybe @venkat-clone can find it