Skip to main content
Answered

Intercom Android SDK Crash


  • New Participant
  • 2 replies

Hi! I'm using Intercom Android SDK 15.15.0 and i caught a crash. The crash happens if you go from the home screen to an empty chat screen -> start a new chat -> send any message -> quickly go back to the home screen -> and press the "Send message" button before the home screen has updated. This sequence of actions leads to a crash with the following logs:
 

java.lang.IllegalStateException: The specified child already has a parent. You must call removeView() on the child's parent first.
	at android.view.ViewGroup.addViewInner(ViewGroup.java:5601)
	at android.view.ViewGroup.addView(ViewGroup.java:5387)
	at android.view.ViewGroup.addView(ViewGroup.java:5327)
	at android.view.ViewGroup.addView(ViewGroup.java:5299)
	at androidx.compose.ui.viewinterop.AndroidViewHolder.<init>(AndroidViewHolder.android.kt:99)
	at androidx.compose.ui.viewinterop.ViewFactoryHolder.<init>(AndroidView.android.kt:332)
	at androidx.compose.ui.viewinterop.ViewFactoryHolder.<init>(AndroidView.android.kt:323)
	at androidx.compose.ui.viewinterop.ViewFactoryHolder.<init>(AndroidView.android.kt:342)
	at androidx.compose.ui.viewinterop.AndroidView_androidKt$createAndroidViewNodeFactory$1$1.invoke(AndroidView.android.kt:275)
	at androidx.compose.ui.viewinterop.AndroidView_androidKt$createAndroidViewNodeFactory$1$1.invoke(AndroidView.android.kt:274)
	at androidx.compose.runtime.changelist.Operation$InsertNodeFixup.execute(Operation.kt:585)
	at androidx.compose.runtime.changelist.Operations.executeAndFlushAllPendingOperations(Operations.kt:310)
	at androidx.compose.runtime.changelist.FixupList.executeAndFlushAllPendingFixups(FixupList.kt:50)
	at androidx.compose.runtime.changelist.Operation$InsertSlotsWithFixups.execute(Operation.kt:552)
	at androidx.compose.runtime.changelist.Operations.executeAndFlushAllPendingOperations(Operations.kt:310)
	at androidx.compose.runtime.changelist.ChangeList.executeAndFlushAllPendingChanges(ChangeList.kt:81)
	at androidx.compose.runtime.CompositionImpl.applyChangesInLocked(Composition.kt:984)
	at androidx.compose.runtime.CompositionImpl.applyChanges(Composition.kt:1013)
	at androidx.compose.runtime.Recomposer$runRecomposeAndApplyChanges$2$1.invoke(Recomposer.kt:685)
	at androidx.compose.runtime.Recomposer$runRecomposeAndApplyChanges$2$1.invoke(Recomposer.kt:585)
	at androidx.compose.ui.platform.AndroidUiFrameClock$withFrameNanos$2$callback$1.doFrame(AndroidUiFrameClock.android.kt:41)
	at androidx.compose.ui.platform.AndroidUiDispatcher.performFrameDispatch(AndroidUiDispatcher.android.kt:109)
	at androidx.compose.ui.platform.AndroidUiDispatcher.access$performFrameDispatch(AndroidUiDispatcher.android.kt:41)
	at androidx.compose.ui.platform.AndroidUiDispatcher$dispatchCallback$1.doFrame(AndroidUiDispatcher.android.kt:69)
	at android.view.Choreographer$CallbackRecord.run(Choreographer.java:2357)
	at android.view.Choreographer$CallbackRecord.run(Choreographer.java:2368)
	at android.view.Choreographer.doCallbacks(Choreographer.java:1504)
	at android.view.Choreographer.lambda$new$0(Choreographer.java:333)
	at android.view.Choreographer.$r8$lambda$LnXpohGOl-DJFbamCZawNX_OpyU(Unknown Source:0)
	at android.view.Choreographer$$ExternalSyntheticLambda0.run(D8$$SyntheticClass:0)
	at android.os.Handler.handleCallback(Handler.java:997)
	at android.os.Handler.dispatchMessage(Handler.java:111)
	at android.os.Looper.loopOnce(Looper.java:237)
	at android.os.Looper.loop(Looper.java:325)
	at android.app.ActivityThread.main(ActivityThread.java:10361)
	at java.lang.reflect.Method.invoke(Native Method)
	at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:635)
	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:961)
	Suppressed: kotlinx.coroutines.internal.DiagnosticCoroutineContextException: [androidx.compose.runtime.PausableMonotonicFrameClock@14e49ee, androidx.compose.ui.platform.MotionDurationScaleImpl@4f02e8f, StandaloneCoroutine{Cancelling}@a0d951c, AndroidUiDispatcher@adf3525]

 

Best answer by skid45

I believe I’ve found a solution to this issue. It seems that your code uses the composable function AndroidView. This function is exactly where the problem I described above occurs. To fix the crash, you just need to add a single line that calls the ViewGroup.removeView(view) method. I tested it with WebView, and it works perfectly.

AndroidView(
    modifier = Modifier.fillMaxSize(),
    factory = { context ->
        SomeView(context).also {
            if (it.parent != null) (it.parent as ViewGroup).removeView(it)
        }
    },
)

 

View original
Did this topic help you find an answer to your question?

2 replies

  • Author
  • New Participant
  • 2 replies
  • Answer
  • April 13, 2025

I believe I’ve found a solution to this issue. It seems that your code uses the composable function AndroidView. This function is exactly where the problem I described above occurs. To fix the crash, you just need to add a single line that calls the ViewGroup.removeView(view) method. I tested it with WebView, and it works perfectly.

AndroidView(
    modifier = Modifier.fillMaxSize(),
    factory = { context ->
        SomeView(context).also {
            if (it.parent != null) (it.parent as ViewGroup).removeView(it)
        }
    },
)

 


  • Author
  • New Participant
  • 2 replies
  • April 28, 2025

Hi Intercom team! Just wondering — do you have any plans to fix this crash in your SDK?


Reply


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings