-
Notifications
You must be signed in to change notification settings - Fork 23
Description
SDK version
5.9.0
Describe the bug
We started using LD around 5.6.1 and we've consistenly gotten quite the high % of crashes in our app when trying to init the LDClient at the start of a session:
Fatal Exception: java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.Object java.util.HashMap.get(java.lang.Object)' on a null object reference
at com.launchdarkly.sdk.android.LDClient.init(LDClient.java:252)
The issue has gotten worse now that we need to insantiate the client closer to the start of the app initialisation, the moment the first screen appears.
Our initialisation setup looks something like this:
val ldConfig = LDConfig.Builder(LDConfig.Builder.AutoEnvAttributes.Enabled)
.applicationInfo(
Components.applicationInfo()
.applicationId(applicationId)
.applicationName(...)
.applicationVersion(...)
.applicationVersionName(...)
)
.mobileKey(...)
.build()
val ldContext = LDContext.builder(ContextKind.DEFAULT, userId)
.name(userName)
...
.build()
LDClient.init(applicationContext as Application, ldConfig, ldContext, 5)To reproduce
There's not a consistent way to reproduce this. Up until now it only happened in crash reports in production.
With the new change (instantiating the client closer to the start of the app) this sometimes happen locally. Killing the app and restarting it usually fixes it.
OS/platform
Android app targeting version 35, compile version 36, minSdk 24.
Most of our userbase uses Samsung Galaxy A40e/A05 Android 13 to 15.