apptentive/apptentive-kit-android

Provider is not registered App Crash

Closed this issue · 1 comments

We have recently migrated from legacy apptentive-android 5.8.4 to the new apptentive-kit-android version 6.5.1. However in doing that upgrade we are now seeing a crash that was previously logged with the legacy project here. I am seeing that in the source code, there is still has a similar way to throw this crash in DependencyProvider#of. This is currently trending as the crash with the most users affected in our Firebase crashlytics, so any help is very much appreciated. We are seeing this on all sorts of devices and OSes in our Firebase crashlytics, but I'll give one user's example info below. One question is would doing Apptentive.register() from inside a coroutine in our Application#onCreate() cause an issue?

Device

Brand: Samsung
Model: Galaxy S23 Ultra

Operating System

Version: Android 14

Crash Logs

 Fatal Exception: java.lang.IllegalArgumentException: Provider is not registered: interface j.a
       at apptentive.com.android.core.DependencyProvider.of(DependencyProvider.java:28)
       at apptentive.com.android.ui.ThemeHelperKt.getShouldApplyAppTheme(ThemeHelper.kt:75)
       at apptentive.com.android.ui.ThemeHelperKt.overrideTheme(ThemeHelper.kt:57)
       at apptentive.com.android.feedback.enjoyment.EnjoymentDialogFragment.onCreateDialog(EnjoymentDialogFragment.kt:35)
       at androidx.fragment.app.DialogFragment.prepareDialog(DialogFragment.java:930)
       at androidx.fragment.app.DialogFragment.onGetLayoutInflater(DialogFragment.java:844)
       at androidx.fragment.app.Fragment.performGetLayoutInflater(Fragment.java)
       at androidx.fragment.app.FragmentStateManager.createView(FragmentStateManager.java:527)
       at androidx.fragment.app.FragmentStateManager.moveToExpectedState(FragmentStateManager.java:272)
       at androidx.fragment.app.FragmentStore.moveToExpectedState(FragmentStore.java:114)
       at androidx.fragment.app.FragmentManager.moveToState(FragmentManager.java:1455)
       at androidx.fragment.app.FragmentManager.dispatchStateChange(FragmentManager.java:3034)
       at androidx.fragment.app.FragmentManager.dispatchActivityCreated(FragmentManager.java:2952)
       at androidx.fragment.app.FragmentController.dispatchActivityCreated(FragmentController.java:263)
       at androidx.fragment.app.FragmentActivity.onStart(FragmentActivity.java:350)
       at androidx.appcompat.app.AppCompatActivity.onStart(AppCompatActivity.java)
       at com.ourfamilywizard.mainactivity.OFWBaseMainActivity.onStart(OFWBaseMainActivity.kt)
       at com.ourfamilywizard.mainactivity.MainActivity.onStart(MainActivity.kt)
       at android.app.Instrumentation.callActivityOnStart(Instrumentation.java:1582)
       at android.app.Activity.performStart(Activity.java:9008)
       at android.app.ActivityThread.handleStartActivity(ActivityThread.java:4198)
       at android.app.servertransaction.TransactionExecutor.performLifecycleSequence(TransactionExecutor.java:225)
       at android.app.servertransaction.TransactionExecutor.cycleToPath(TransactionExecutor.java:205)
       at android.app.servertransaction.TransactionExecutor.executeLifecycleState(TransactionExecutor.java:177)
       at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:98)
       at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2685)
       at android.os.Handler.dispatchMessage(Handler.java:106)
       at android.os.Looper.loopOnce(Looper.java:230)
       at android.os.Looper.loop(Looper.java:319)
       at android.app.ActivityThread.main(ActivityThread.java:8919)
       at java.lang.reflect.Method.invoke(Method.java)
       at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:578)
       at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1103)
    

I wanted to write up a follow-up here for anyone else that comes across this issue. We were able to reproduce the crash where a user leaves the Love Dialog up in our app (doesn't respond), puts the app in the background, the app is killed (we used Developer Options to help with recreating this), then the user brings the app back to the foreground. Crash!

The root cause of our issue that we narrowed down with the help of Alchemer support is we had put Apptentive.register() inside a coroutine in our Application#onCreate() due to noticing some disk read violations from this sdk. Doing that meant when the app was brought to the foreground, trying to recreate the dialog, it called some operations before the sdk was registered again due to it being on a background thread.

So the lesson learned is, do NOT set up Apptentive.register() on a background thread. Also, the sdk offers a boolean for seeing if the sdk is already registered with Apptentive.registered so we are also using that for an extra check to try and prevent crashes in the future as well.