Cấn Văn Nghị
06/22/2025, 9:39 AMUnable to start activity ComponentInfo{com.example.myapp/.MainActivity}:
java.lang.RuntimeException: Window couldn't find content container view
This doesn't happen every time — it's random and seems to occur more frequently on cold starts or after backgrounding the app.
Has anyone faced this issue before or know what might be causing it?
Any help or guidance would be greatly appreciated.
Thanks in advance!Chrimaeon
06/22/2025, 9:45 AMCấn Văn Nghị
06/22/2025, 9:51 AMCaused by java.lang.RuntimeException: Window couldn't find content container view
at com.android.internal.policy.PhoneWindow.generateLayout(PhoneWindow.java:2806)
at com.android.internal.policy.PhoneWindow.installDecor(PhoneWindow.java:2870)
at com.android.internal.policy.PhoneWindow.getDecorView(PhoneWindow.java:2229)
at androidx.activity.compose.ComponentActivityKt.setContent(ComponentActivity.kt:55)
at androidx.activity.compose.ComponentActivityKt.setContent$default(ComponentActivity.kt:51)
at com.sample.MainActivity.onCreate(MainActivity.kt:63)
at android.app.Activity.performCreate(Activity.java:8733)
at android.app.Activity.performCreate(Activity.java:8702)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1384)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3967)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:4131)
at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:101)
at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:135)
at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:95)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2546)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loopOnce(Looper.java:223)
at android.os.Looper.loop(Looper.java:324)
at android.app.ActivityThread.main(ActivityThread.java:8547)
at java.lang.reflect.Method.invoke(Method.java)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:582)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1061)
The crash happened at setContent method:
@AndroidEntryPoint
class MainActivity : ComponentActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
createNotificationChannel()
observeOnActivityDestroy()
setContent {...}
}
...
}