Overview › Lifecycle Issues

Fragment / Activity Lifecycle Issues

Fragment-detach crashes, leaked listeners, view-binding access after onDestroyView, observer scope mismatches, and fragment-transaction state-loss patterns. These are the most common production crash sources in Android apps.

33 lifecycle findings
13
CRITICAL
Critical
13
High
20
Medium
0
Hot files
15

distinct files

Lifecycle pitfalls covered

PatternRiskFix
getActivity() in callbackNPE if fragment detachedGuard with isAdded(), capture activity early
observe(this) in fragmentObserver outlives view; double-render after rotationUse viewLifecycleOwner
_binding!! after onDestroyViewNPE in async callbackGuard with _binding?.let { … }
addOnGlobalLayoutListener never removedView-tree leaks fragmentPair with removeOnGlobalLayoutListener in onDestroyView
commitAllowingStateLoss() after onSaveInstanceStateHides bugs; lost UI stateWrap in if (!isStateSaved), queue otherwise
Handler() as anonymous inner classHolds outer fragment refUse static handler + WeakReference, or coroutines
NetworkCallback not unregisteredFires after detach → NPEUnregister in onDestroyView
33 shown
Costco Android · Code Review Report · Generated 2026-05-07 · 626 machine-curated findings