Just got a curious set of crashes showing up in cr...
# coroutines
m
Just got a curious set of crashes showing up in crashlytics as soon as I deployed a release build to the Play Store. So presumably the 12 crashes (12 users) are coming from Play Store processing. However, so far the pre-launch report isn’t showing any issues.
Copy code
Caused by java.lang.NoSuchMethodError: No interface method H(LR6/j;Ljava/lang/Throwable;)V in class Lkotlinx/coroutines/CoroutineExceptionHandler; or its super classes (declaration of 'kotlinx.coroutines.CoroutineExceptionHandler' appears in /data/app/~~Z-fAOaBS5ZLKRSyO1AxrHQ==/androidx.test.tools.crawler-a5LrOqdluFlu95bOrqipNw==/base.apk)
       at kotlinx.coroutines.internal.CoroutineExceptionHandlerImpl_commonKt.handleUncaughtCoroutineException(CoroutineExceptionHandlerImpl_common.kt:34)
       at kotlinx.coroutines.CoroutineExceptionHandlerKt.handleCoroutineException(CoroutineExceptionHandler.kt:24)
       at kotlinx.coroutines.StandaloneCoroutine.handleJobException(Builders.common.kt:190)
       at kotlinx.coroutines.JobSupport.finalizeFinishingState(JobSupport.kt:228)
       at kotlinx.coroutines.JobSupport.tryMakeCompletingSlowPath(JobSupport.kt:907)
       at kotlinx.coroutines.JobSupport.tryMakeCompleting(JobSupport.kt:864)
       at kotlinx.coroutines.JobSupport.makeCompletingOnce$kotlinx_coroutines_core(JobSupport.kt:829)
       at kotlinx.coroutines.AbstractCoroutine.resumeWith(AbstractCoroutine.kt:97)
       at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:46)
       at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:102)
       at kotlinx.coroutines.scheduling.CoroutineScheduler.runSafely(CoroutineScheduler.java:585)
       at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.executeTask(CoroutineScheduler.kt:802)
       at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.runWorker(CoroutineScheduler.kt:706)
       at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.run(CoroutineScheduler.kt:693)
Note - there was no issue with a release I made yesterday, and it’s very unlikely the few changes I made since then are related to this.
j
Looks like some code was compiled against some version of the coroutines library, but now it's run with another version on the classpath
m
So could it be that Play Store is perhaps running its own tests on the APK but using a different coroutines version without doing the proper check first?
j
I haven't done Android dev in a long time, but shouldn't your APK contain all its dependencies? I doubt the Play Store provides its own version of coroutines 🤔
m
Yes, the APK would contain its own version of coroutines, but I suppose that doesn’t stop some other runtime environment (perhaps for testing) using its own version of coroutines and executing code within the APK. Otherwise how else could this crash occur? The APK runs fine by itself.
j
The method name seems obfuscated by the way, so maybe proguard is responsible for this. Note that this is a runtime error, so in order to be sure the "APK runs fine by itself" you would need to be certain that this code path is actually used
m
Hmm, looking through the mapping file, could this be it?
Copy code
0:4:void handleException(R6.CoroutineContext,java.lang.Throwable):0:0 -> H
      # {"id":"com.android.tools.r8.synthesized"}
      # {"id":"com.android.tools.r8.residualsignature","signature":"(LR6/j;Ljava/lang/Throwable;)V"}
Here are my coroutines proguard rules:
Copy code
-keepnames class kotlinx.coroutines.internal.MainDispatcherFactory {}
-keepnames class kotlinx.coroutines.CoroutineExceptionHandler {}
-keepclassmembernames class kotlinx.** {
    volatile <fields>;
}
I changed those rules to:
Copy code
-keepnames class kotlinx.** { *; }
but now get this instead:
Copy code
Caused by java.lang.NoSuchFieldError: No static field Key of type Lkotlinx/coroutines/CoroutineExceptionHandler$Key; in class Lkotlinx/coroutines/CoroutineExceptionHandler; or its superclasses (declaration of 'kotlinx.coroutines.CoroutineExceptionHandler' appears in /data/app/~~5Ur7lr70UpgMuUJAshTU-A==/androidx.test.tools.crawler-McgI1YcItzv6kKg8CsNnmQ==/base.apk)
Someone else also asking about it here: https://stackoverflow.com/questions/78041019/google-play-testing-app-crash-java-lang-nosuchfielderror-no-field-key-of-type#comment137776357_78064831
j
I see. Well sorry Mark I'm a bit out of my depth here, as I have very little experience with both proguard and Android APK publication 😅 hopefully someone else can weigh in, here
m
It’s okay, me too. I appreciate your help anyway. I just joined that Firebase slack and they are talking about the same issue, so I’ll continue over there.
👍 1