# App crashes when leaving Zoom session using UI Toolkit in Jetpack Compose (NullPointerException in UiToolkitView.cleanup)

**URL:** <https://devforum.zoom.us/t/app-crashes-when-leaving-zoom-session-using-ui-toolkit-in-jetpack-compose-nullpointerexception-in-uitoolkitview-cleanup/135081>\
**Category:** UI ToolKit\
**Tags:** video-sdk, android\
**Created:** [July 10, 2025, 7:55pm UTC](https://devforum.zoom.us/t/app-crashes-when-leaving-zoom-session-using-ui-toolkit-in-jetpack-compose-nullpointerexception-in-uitoolkitview-cleanup/135081 "2025-07-10T19:55:28Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![DineshSarma](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/dineshsarma/32/51308_2.png) [@DineshSarma](https://devforum.zoom.us/u/DineshSarma)\
**Post date:** [July 10, 2025, 7:55pm UTC](https://devforum.zoom.us/t/app-crashes-when-leaving-zoom-session-using-ui-toolkit-in-jetpack-compose-nullpointerexception-in-uitoolkitview-cleanup/135081/1 "2025-07-10T19:55:28Z")

</div>

Hi Team,

I’m using the Zoom UI Toolkit (`implementation 'us.zoom.uitoolkit:uitoolkit:2.1.10-1'`) to implement call functionality in my Android app, which is built using Kotlin and Jetpack Compose.

The issue I’m facing is that when the user clicks the “Leave Call” icon to exit a Zoom session, the `UiToolkitView` is removed immediately as expected, but the app crashes 1–2 seconds later.

Here’s the crash log:

```auto
Process: org.brainhealth.bhp_android.dev, PID: 10736
 java.lang.NullPointerException: Attempt to invoke interface method 'int us.zoom.sdk.ZoomVideoSDKShareHelper.stopShare()' on a null object reference
 at us.zoom.uitoolkit.UiToolkitView.cleanup(UiToolkitView.kt:136)
 at us.zoom.uitoolkit.UiToolkitView.access$cleanup(UiToolkitView.kt:30)
 at us.zoom.uitoolkit.UiToolkitView$videoSdkListener$1.onSessionLeave(UiToolkitView.kt:70)
 at us.zoom.internal.ZoomVideoSDKDelegateHelper$1$4.run(ZoomVideoSDKDelegateHelper.java:3)
 at android.os.Handler.handleCallback(Handler.java:991)
 at android.os.Handler.dispatchMessage(Handler.java:102)
 at android.os.Looper.loopOnce(Looper.java:232)
 at android.os.Looper.loop(Looper.java:317)
 at android.app.ActivityThread.main(ActivityThread.java:8934)
 at java.lang.reflect.Method.invoke(Native Method)
 at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:591)
 at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:911)

```

**Note:** This `NullPointerException` occurs after the `onViewStopped()` method of the `UiToolkitView.Listener` is triggered.

Could you please advise on what might be causing this crash and how to properly clean up or prevent it?

Thanks in advance!

---

<div class="post-metadata">

**Author:** ![ticorrian.heard](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/ticorrian.heard/32/70213_2.png) [@ticorrian.heard](https://devforum.zoom.us/u/ticorrian.heard)\
**Post date:** [July 14, 2025, 4:46pm UTC](https://devforum.zoom.us/t/app-crashes-when-leaving-zoom-session-using-ui-toolkit-in-jetpack-compose-nullpointerexception-in-uitoolkitview-cleanup/135081/2 "2025-07-14T16:46:31Z")

</div>

Hi @DineshSarma It looks like the code is attempting to call an Share SDK related object after the meeting session has already been disconnected. Can you detail if any screen sharing features were being used when the user ended the meeting?

---

<div class="post-metadata">

**Author:** ![DineshSarma](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/dineshsarma/32/51308_2.png) [@DineshSarma](https://devforum.zoom.us/u/DineshSarma)\
**Post date:** [July 14, 2025, 9:52pm UTC](https://devforum.zoom.us/t/app-crashes-when-leaving-zoom-session-using-ui-toolkit-in-jetpack-compose-nullpointerexception-in-uitoolkitview-cleanup/135081/3 "2025-07-14T21:52:16Z")

</div>

Thank you @ticorrian.heard  
I am not handling anything manually, just using UiToolKitView, following is my how my implementation looks like:

// declaration  
val sessionContext = SessionContext(sessionName, jwtToken, userName, password)  
val uiToolkitView = UiToolkitView(context)

// to join the session  
uiToolkitView.joinSession(sessionContext)  
//adding click listener  
uiToolkitView.addListener(object : UiToolkitView.Listener {})

// setting UiToolKitView into AndroidView  
Box(  
modifier = Modifier  
.fillMaxWidth()  
.fillMaxHeight()  
) {  
AndroidView(  
modifier = Modifier  
.size(height = screenHeight.dp, width = screenWidth.dp)  
.align(Alignment.Center),  
factory = { uiToolkitView }  
)  
}
