[英]Coroutine cancellation with HMS
I'm adapting my application to HMS.我正在使我的应用程序适应 HMS。 When I cancel launched coroutine, catch and trying to log CancellationException to HMS crashlytics, my app crashed with strange logs.
当我取消启动的协程,捕获并尝试将 CancellationException 记录到 HMS crashlytics 时,我的应用程序因奇怪的日志而崩溃。 If I omit this exception and didn't log it to crashlytics using method
AGConnectCrash.getInstance().recordException(throwable)
coroutine cancellation doesn't lead to app crash.如果我忽略了这个异常并且没有使用方法
AGConnectCrash.getInstance().recordException(throwable)
将其记录到 crashlytics 中,协程取消不会导致应用程序崩溃。 Can someone help with that problem?有人可以帮助解决这个问题吗?
Crash logs崩溃日志
java.lang.ArrayIndexOutOfBoundsException: length=0; index=0 at com.huawei.agconnect.crash.internal.bean.Event$Builder.summary(Unknown Source:5) at com.huawei.agconnect.crash.internal.log.AGCCrashNonFatal.collectInfo(Unknown Source:41) at com.huawei.agconnect.crash.internal.log.AGCCrashNonFatal.logException(Unknown Source:0) at com.huawei.agconnect.crash.internal.log.AGCCrashCore$4.run(Unknown Source:6) at java.util.concurrent.ThreadPoolExecutor.processTask(ThreadPoolExecutor.java:1187) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1152) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641) at java.lang.Thread.run(Thread.java:784)
SomeCodeExample一些代码示例
private fun loadData() {
job?.cancel()
job = viewModelScope.launch {
try {
data.value = someApiCall()
} catch (e: Exception) {
Logger.log(e)
}
}
}
Where在哪里
object Logger {
fun log(e: Throwable?) {
if (e != null) {
AGConnectCrash.getInstance().recordException(e)
}
}
}
I think your input parameter type is incorrect.我认为您的输入参数类型不正确。 You put the string instead of the stack information.
你放的是字符串而不是堆栈信息。 You are advised to enter the document type.
建议输入单据类型。 If a character string is forcibly entered, the system crashes.
强行输入字符串会导致系统崩溃。 And in later versions, a judgment protection mechanism will be added.
并且在以后的版本中,会增加判断保护机制。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.