apptentive/apptentive-kit-android

Not possible to have a delayed init as on version 5.x

Opened this issue · 2 comments

Hi,

I need to have the init customizable and defined by an API setting, and right now when I don't register the app just crashes or it doesn't load the views as it should.

Apptentive.INSTANCE.isRegistered does not work to prevent it.

java.lang.NoClassDefFoundError: apptentive.com.android.util.Log
                                                                                              	at apptentive.com.android.util.Log.d(Unknown Source:0)
                                                                                              	at apptentive.com.android.feedback.ApptentiveNullClient.getUnreadMessageCount(ApptentiveClient.kt:77)
                                                                                              	at apptentive.com.android.feedback.Apptentive.getUnreadMessageCount(Apptentive.kt:520)
                                                                                              	at com.smithmicro.safepath.family.core.analytics.apptentive.ApptentiveRatingEngine.getUnreadMessageCount(ApptentiveRatingEngine.java:132)

Your logger only gets initialized after registering. So you try to log if not registered and it crashes because there's no logger.
I have to check before all methods if its registered.

@rkardo58

Yes, that's how it's currently intended to work. Apptentive needs to be registered in order for any other part of the SDK to work, including the logger.

But this is an area where we can do better, and we'll work on improving this in the near future.

In the meantime, something you can do to check if the SDK is registered is to use the register callback method shown here.

Also, if you can provide some more info (maybe code snippets) of how you're doing the "init customizable and defined by an API setting" part of your code, we could try to repro this same scenario on our end.

Thanks.

cc @CaseyApptentive @NickYeltonApptentive