From 337e8a30add11ef0af6bbd636200aa4c20fef410 Mon Sep 17 00:00:00 2001 From: avit Date: Wed, 29 Jul 2026 18:36:05 +0300 Subject: [PATCH] Fix crash attaching custom row to non-AppCompat activities BottomTabsCustomRowAttacher is registered process-wide, so tryAttach() runs for every activity in the app. It called Activity.findViewById(), which on an AppCompat activity routes through AppCompatDelegateImpl and forces createSubDecor() -- that throws IllegalStateException unless the activity's theme derives from Theme.AppCompat. Any activity inheriting a non-AppCompat theme therefore crashed on creation. Resolve android.R.id.content through the decor view instead, which never engages AppCompatDelegate. Activity.findViewById() already delegates to getWindow().getDecorView().findViewById(), so behaviour is unchanged for activities that do have a compatible theme. Co-Authored-By: Claude Opus 5 (1M context) --- .../customrow/BottomTabsCustomRowAttacher.kt | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/android/src/main/java/com/reactnativenavigation/customrow/BottomTabsCustomRowAttacher.kt b/android/src/main/java/com/reactnativenavigation/customrow/BottomTabsCustomRowAttacher.kt index 064b854cf6..0efcb47aa3 100644 --- a/android/src/main/java/com/reactnativenavigation/customrow/BottomTabsCustomRowAttacher.kt +++ b/android/src/main/java/com/reactnativenavigation/customrow/BottomTabsCustomRowAttacher.kt @@ -90,10 +90,10 @@ internal object BottomTabsCustomRowAttacher : Application.ActivityLifecycleCallb } private fun tryAttach(activity: Activity) { - val scanRoot = activity.window?.decorView as? ViewGroup - ?: activity.findViewById(android.R.id.content) as? ViewGroup - ?: return - val overlayHost = activity.findViewById(android.R.id.content) as? ViewGroup + val scanRoot = activity.window?.decorView as? ViewGroup ?: return + // Resolve through the view tree: AppCompatActivity.findViewById() forces + // createSubDecor(), which throws unless the activity's theme is Theme.AppCompat. + val overlayHost = scanRoot.findViewById(android.R.id.content) as? ViewGroup ?: scanRoot forEachBottomTabs(scanRoot) { bottomTabs ->