Answered

Fatal error with Android SDK: java.lang.NullPointerException: ConversationHeaderV2

  • 13 March 2024
  • 3 replies
  • 44 views

I am getting a crash when using the Android SDK via a Flutter-based application. This crash is occurring on a Pixel 8 running Android 14.

  • intercom_flutter 8.1.1
    • This uses Android SDK 15.6.3
  • Also tested against intercom 8.0.9, which uses SDK 16.5.1
  • Built using minSdkVersion 21, compileSdkVersion being Flutter’s compile SDK version.  Java compatibility set to JavaVersion.VERSION_1_8

This crash occurs when clicking to access recent messages.

E/AndroidRuntime(32192): java.lang.NullPointerException: Parameter specified as non-null is null: method io.intercom.android.sdk.m5.conversation.states.ConversationHeaderV2.<init>, parameter subtitle
E/AndroidRuntime(32192):     at io.intercom.android.sdk.m5.conversation.states.ConversationHeaderV2.<init>(Unknown Source:8)
E/AndroidRuntime(32192):     at io.intercom.android.sdk.m5.conversation.reducers.HeaderReducerKt.reduceHeaderV2(HeaderReducer.kt:48)
E/AndroidRuntime(32192):     at io.intercom.android.sdk.m5.conversation.reducers.ConversationReducer.computeUiState$intercom_sdk_base_release(ConversationReducer.kt:77)
E/AndroidRuntime(32192):     at io.intercom.android.sdk.m5.conversation.ConversationViewModel$special$$inlined$map$1$2.emit(Emitters.kt:224)
E/AndroidRuntime(32192):     at kotlinx.coroutines.flow.StateFlowImpl.collect(StateFlow.kt:396)
E/AndroidRuntime(32192):     at kotlinx.coroutines.flow.StateFlowImpl$collect$1.invokeSuspend(Unknown Source:15)
E/AndroidRuntime(32192):     at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
E/AndroidRuntime(32192):     at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:106)
E/AndroidRuntime(32192):     at android.os.Handler.handleCallback(Handler.java:959)
E/AndroidRuntime(32192):     at android.os.Handler.dispatchMessage(Handler.java:100)
E/AndroidRuntime(32192):     at android.os.Looper.loopOnce(Looper.java:232)
E/AndroidRuntime(32192):     at android.os.Looper.loop(Looper.java:317)
E/AndroidRuntime(32192):     at android.app.ActivityThread.main(ActivityThread.java:8501)
E/AndroidRuntime(32192):     at java.lang.reflect.Method.invoke(Native Method)
E/AndroidRuntime(32192):     at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:552)
E/AndroidRuntime(32192):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:878)
E/AndroidRuntime(32192):     Suppressed: kotlinx.coroutines.internal.DiagnosticCoroutineContextException: [StandaloneCoroutine{Cancelling}@3100cb8, Dispatchers.Main.immediate]

Further investigation and testing related to Android by incrementally updating

  • intercom_flutter:intercom_flutter: 8.0.4 -- does not cause crash
  • intercom_flutter: 8.0.5 -- does not cause crash
  • intercom_flutter: 8.0.6 -- does not cause crash
  • intercom_flutter: 8.0.7 -- does not cause crash
  • intercom_flutter: 8.0.8 -- FTBFS jetified error
  • intercom_flutter: 8.0.9 -- crash triggered

intercom_flutter 8.0.9 updates the Android SDK to 15.6.0. 8.0.5 was the release prior that updated the Android SDK to 15.5.0, so a regression was introduced between 15.5.0 and 15.6.0.

icon

Best answer by cameron.gumley 15 March 2024, 05:17

View original

3 replies

Userlevel 2
Badge +3

Hi @Joshua Strobl -- Cam from the Intercom Engineering Support team here!

Just wanted to touch base from our team to let you know that, given Intercom does not have an official SDK built for Flutter and the Flutter package you’re using is built and managed by a third-party, we aren’t able to provide support for issues like this when they come up. That being said, perhaps the community here has some experience with this issue and can provide some advice or I’d certainly recommend reaching out to the team that built the package as they’ll be best placed to look into this for you 👍

The source code for intercom_flutter can be trivially reviewed at https://github.com/v3rm0n/intercom_flutter/blob/master/intercom_flutter/android/src/main/kotlin/io/maido/intercom/IntercomFlutterPlugin.kt and https://github.com/v3rm0n/intercom_flutter/blob/master/intercom_flutter/lib/intercom_flutter.dart

In IntercomFlutterPlugin.kt, it initializes an Android client which is provided from the Intercom Android SDK. It is effectively a fancy proxy to Intercom’s own SDK and for exposing various events, it contains a minimal set of logic for that to work. For example, it’s “displayCarousel” function calls Intercom’s own functionality: Intercom.client().presentContent(IntercomContent.Carousel(carouselId))

In intercom_flutter.dart, it’s just calling the instance for the specific mobile platform (Android or iOS). As an example, the displayCarousel function when called on Android calls intercom_flutter Android platform code, which calls out to Intercom’s SDK for Android.

We both can see from the stack trace above that the issue is triggered internally to Intercom Android SDK, not intercom_flutter. The expectation is that this will be forwarded to the team responsible for the Android SDK so they may bisect the issue raised between SDK 15.5.0 and 15.6.0 which triggers the crash. Thanks!

@Cam G. Please take a look at my message above and forward it to the team. Thanks.

Reply