flutter_in_app_update
flutter_in_app_update copied to clipboard
android.content.IntentSender$SendIntentException
Hello,
I am getting this from production users
Caused by android.content.IntentSender$SendIntentException
at android.app.Activity.startIntentSenderForResultInner(Activity.java:4908)
at android.app.Activity.startIntentSenderForResult(Activity.java:4877)
at com.google.android.play.core.appupdate.d.startIntentSenderForResult(d.java:9)
at com.google.android.play.core.appupdate.e.a(e.java:23)
at com.google.android.play.core.appupdate.e.a(e.java:9)
at de.ffuf.in_app_update.InAppUpdatePlugin$onActivityResumed$1.a(InAppUpdatePlugin.java:72)
at de.ffuf.in_app_update.InAppUpdatePlugin$onActivityResumed$1.a(InAppUpdatePlugin.java:2)
I don't know what the exact cause is, but looking at the code there I can see it can be improved.
requireNotNull(activityProvider?.activity()) {
updateResult?.error(
"in_app_update requires a foreground activity",
null,
null
)
Unit
}
appUpdateManager?.startUpdateFlowForResult(
appUpdateInfo,
AppUpdateType.IMMEDIATE,
activityProvider?.activity(),
REQUEST_CODE_START_UPDATE
)
You should save a reference returned from activityProvider?.activity() to a local variable before working with it. That is because activityProvider?.activity() can give you activity on a first call but null on the second. This can easily happen if some other thread in other code resets the provider. And you should never assume this won't happen when working with this kind of framework. Once improved, the code will become:
val activity = activityProvider?.activity()
requireNotNull(activity) {
updateResult?.error(
"in_app_update requires a foreground activity",
null,
null
)
Unit
}
appUpdateManager?.startUpdateFlowForResult(
appUpdateInfo,
AppUpdateType.IMMEDIATE,
activity,
REQUEST_CODE_START_UPDATE
)
Also I don't think you want to call requireNotNull(activity)
there. Its documentation says Throws an [IllegalArgumentException] with the result of calling [lazyMessage] if the [value] is null. Otherwise returns the not null value.
Meaning it will call the updateResult?.error
code, but then it will crash the Android process with a IllegalArgumentException. Not sure that is an intended behaviour.
I am seeing a similar Exception in Play console as well:
in_app_update: v1.1.11
java.lang.RuntimeException: at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run (RuntimeInit.java:549) at com.android.internal.os.ZygoteInit.main (ZygoteInit.java:994) Caused by: java.lang.reflect.InvocationTargetException: at java.lang.reflect.Method.invoke (Native Method) at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run (RuntimeInit.java:539) Caused by: android.content.IntentSender$SendIntentException: at android.app.Activity.startIntentSenderForResultInner (Activity.java:5519) at android.app.Activity.startIntentSenderForResult (Activity.java:5487) at com.google.android.play.core.appupdate.c.startIntentSenderForResult (Unknown Source:9) at com.google.android.play.core.appupdate.d.startUpdateFlowForResult (Unknown Source:21) at com.google.android.play.core.appupdate.d.startUpdateFlowForResult (Unknown Source:9) at de.ffuf.in_app_update.InAppUpdatePlugin$onActivityResumed$1.onSuccess (InAppUpdatePlugin.kt:156) at de.ffuf.in_app_update.InAppUpdatePlugin$onActivityResumed$1.onSuccess (InAppUpdatePlugin.kt:29) at com.google.android.play.core.tasks.e.run (Unknown Source:27) at android.os.Handler.handleCallback (Handler.java:914) at android.os.Handler.dispatchMessage (Handler.java:100) at android.os.Looper.loop (Looper.java:225) at android.app.ActivityThread.main (ActivityThread.java:7563)
Any updates on this?
I released 4.0.0 which should fix this issue