-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Module with the Main dispatcher is missing with version 1.3.0-RC2 and other versions as well #1532
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
I have got the same crash in logs for Samsung S8 Plus on Android Pie. He got this crash 14 times in a day (and probably uninstalled the app, idk). I use version 1.2.1 of coroutines |
1.3.0 version works for me on Android, but 1.3.2 has the same error. I use android version of coroutines
Nothing helps - only downgrade. The problem exist in debug build as well, so it is not connected with Proguard. |
We will hopefully fix this issue in #1572 |
i wasnt able to reproduce it at all on any of our real devices nor emulators, and i am not familiar enough with service loader to be of any help here. the crashes are so sporadic, its about 1 user in 500, and by looking at the apk's i do not see anything problematic. |
Most likely in the next release (1.3.3) |
User reported crash: ``` java.lang.IllegalStateException: Module with the Main dispatcher is missing. Add dependency providing the Main dispatcher, e.g. 'kotlinx-coroutines-android' ``` Based on comments in related GitHub ticket, attempting to see if downgrading `kotlinx-coroutines` to `1.3.0` [0] and adding Proguard rules [1] fixes the issue. [0] Kotlin/kotlinx.coroutines#1532 (comment) [1] Kotlin/kotlinx.coroutines#1532 (comment) Fixes #1856
User reported crash: ``` java.lang.IllegalStateException: Module with the Main dispatcher is missing. Add dependency providing the Main dispatcher, e.g. 'kotlinx-coroutines-android' ``` Based on comments in related GitHub ticket, attempting to see if downgrading `kotlinx-coroutines` to `1.3.0` [0] and adding Proguard rules [1] fixes the issue. [0] Kotlin/kotlinx.coroutines#1532 (comment) [1] Kotlin/kotlinx.coroutines#1532 (comment) Fixes #1856
Hi, any news when 1.3.3 is going to be released with the fix from #1572 ? |
During this year :) |
This error just happened to my Huawei device. |
A workaround seems to be using: |
could not agree more with the "critical bug" part, not just because i am experiencing it, but because it is so random and hard to reproduce. I have actually managed to stumble into it with a debug build, but it went away after an invalidate cache/restart so not much to lean on with that. Thanks for the workaround, but ill wait for the merge, whenever that might happen. |
Fixed in 1.3.3 |
Most notably coroutines may fix IllegalStateException: Module with the Main dispatcher is missing. Kotlin/kotlinx.coroutines#1532
Also had to upgrade Kotlin version to avoid a coroutines error: "Main dispatcher is missing" Kotlin/kotlinx.coroutines#1532
This crash has been haunting me occasionally for a few months now:
This is the latest crash with coroutines version kotlinx-coroutines-android:1.3.0-RC2, AS 3.5, Gradle 5.1.1, AGP 3.4.2,
R8 enabled, version 1.4.94.
This particular crash happened on Samsung 9 running android 9, but i have also seen the crash (crashlytics) it on other versions and devices as well:
Redmi 4x with android 7.1.2 and the following properties:
AS 3.4.2, gradle 5.1.1, AGP 3.4.1
and on older versions of coroutines, this time bundled with core:kotlinx-coroutines-android:1.1.1, gradle 5.1.1 and AGP 3.4.1 on pocophone f1 running android 9, samsung j5 running android 8.1.0.
i have been unable to reproduce this issue on any of our production builds. I have also gone through all the issues related to MissingMainCoroutineDispatcher i could find here and on SO, yet none of the solutions seems to work. Some suggested that using -core as well -android might be related, but this happens as well without -core. Other suggested the packaging might get corrupted during when signing the app, but we have used the same build flow before without issues. i have also added the following proguard rules, while fully aware those are not required when using R8:
`# Coroutines
ServiceLoader support
-keepnames class kotlinx.coroutines.internal.MainDispatcherFactory {}
-keepnames class kotlinx.coroutines.CoroutineExceptionHandler {}
-keepnames class kotlinx.coroutines.android.AndroidExceptionPreHandler {}
-keepnames class kotlinx.coroutines.android.AndroidDispatcherFactory {}
Most of volatile fields are updated with AFU and should not be mangled
-keepclassmembernames class kotlinx.** {
volatile ;
}`
Also without any visible effect. I have also seen suggestions regarding the signing process and specifically the final production apk, and the META-INF/services folder - and it looks like this when i open the apk in AS:

So not sure when to go from here and what, and would appreciate any insights you may have on this.
The text was updated successfully, but these errors were encountered: