Tuesday, 2 February 2021

JobCancellationException with in-app updates

I've noticed that some of the users have issues to use flexible in-app update, the JobCancellationException: Job was cancelled is thrown with incomprehensible stack trace:

at dalvik.system.VMStack.getThreadStackTrace(VMStack.java)
at java.lang.Thread.getStackTrace(Thread.java:1538)
at java.lang.ThreadGroup.uncaughtException(ThreadGroup.java:1068)
at java.lang.ThreadGroup.uncaughtException(ThreadGroup.java:1063)
at java.lang.Thread.dispatchUncaughtException(Thread.java:1955)

Unfortunately, I don't which part of the code is causing the issue. This is the only coroutine related code, staying in MyViewModel:

init {
    viewModelScope.launch {
        try {
            appUpdateManager.requestUpdateFlow().collect { appUpdateResult ->
                // Do something with result.
            }
        } catch (e: InstallException) {
            // Do something with an error.
        }
    }
}

fun requestUpdate(fragment: Fragment) {
    viewModelScope.launch {
        try {
            val appUpdateInfo = appUpdateManager.requestAppUpdateInfo()

            appUpdateManager.startUpdateFlowForResult(
                appUpdateInfo,
                AppUpdateType.FLEXIBLE,
                fragment,
                REQUEST_CODE
            )
        } catch (e: IntentSender.SendIntentException) {
        }
    }
}

I suspect that code inside requestUpdateFlow() is calling offer while the coroutine job is already cancelled and I can't see the exact stacktrace, because Play Core library is obfuscated?

I'm using following versions of the libraries:

"com.google.android.play:core:1.7.2"
"com.google.android.play:core-ktx:1.7.0"


from JobCancellationException with in-app updates

No comments:

Post a Comment