Skip to content

IllegalStateException: Module with the Main dispatcher is missing #799

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

Closed
trashkalmar opened this issue Nov 6, 2018 · 16 comments
Closed
Assignees
Labels

Comments

@trashkalmar
Copy link

Our user with Xiaomi Redmi Note 4 device (Android 7.1.2) suddenly started to experience crash that had to be fixed with #657.
We're unable to reproduce it on our side. Here is reproducer app with the same lib dependencies as our main application: https://www.dropbox.com/s/eay696h9qmxjl5e/sample.zip?dl=1

AndroidX AppCompat: 1.0.0
Kotlin: 1.3.0
Coroutines: 1.0.0
Gradle wrapper: 4.10.2-bin

Caused by java.lang.IllegalStateException: Module with the Main dispatcher is missing. Add dependency providing the Main dispatcher, e.g. 'kotlinx-coroutines-android'
       at kotlinx.coroutines.MissingMainCoroutineDispatcher.missing(Dispatchers.kt:123)
       at kotlinx.coroutines.MissingMainCoroutineDispatcher.dispatch(Dispatchers.kt:116)
       at kotlinx.coroutines.DispatchedKt.resumeCancellable(Dispatched.kt:279)
       at kotlinx.coroutines.intrinsics.CancellableKt.startCoroutineCancellable(Cancellable.kt:23)
       at kotlinx.coroutines.CoroutineStart.invoke(CoroutineStart.kt:109)
       at kotlinx.coroutines.AbstractCoroutine.start(AbstractCoroutine.kt:160)
       at kotlinx.coroutines.BuildersKt__Builders_commonKt.launch(Builders.common.kt:54)
       at kotlinx.coroutines.BuildersKt.launch(Unknown Source:1)
       at kotlinx.coroutines.BuildersKt__Builders_commonKt.launch$default(Builders.common.kt:47)
       at kotlinx.coroutines.BuildersKt.launch$default(Unknown Source:1)
       at our.app.ui.base.BaseActivity.startAsync(BaseActivity.kt:229)
       at our.app.ui.main.MainActivity.refreshServerConfig(MainActivity.kt:63)
       at our.app.ui.main.MainActivity.onCreate(MainActivity.kt:134)
       at android.app.Activity.performCreate(Activity.java:6738)
       at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1119)
       at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2652)
       at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2766)
       at android.app.ActivityThread.-wrap12(ActivityThread.java)
       at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1507)
       at android.os.Handler.dispatchMessage(Handler.java:102)
       at android.os.Looper.loop(Looper.java:154)
       at android.app.ActivityThread.main(ActivityThread.java:6236)
       at java.lang.reflect.Method.invoke(Method.java)
       at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:891)
       at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:781)
@qwwdfsad qwwdfsad self-assigned this Nov 6, 2018
@trashkalmar
Copy link
Author

UPD: We also use jetifier processor:

classpath "com.android.tools.build.jetifier:jetifier-processor:1.0.0-alpha10"

Newer version (1.0.0-beta02) is not compatible with databinding.

@Arayldan
Copy link

Arayldan commented Nov 8, 2018

Uncomment the last two lines in your sample's proguard-rules.pro

@ghost
Copy link

ghost commented Nov 12, 2018

I enabled R8 and it is the problem. Only proguard no problem. coroutines version 1.0.1

@evgentset
Copy link

I has same issue and fixed it by adding options from coroutines.pro to proguard. Hope it helps somebody.

@marlboro3420
Copy link

marlboro3420 commented Dec 29, 2018

@evgentset thanks, worked for me. coroutines version 1.0.1

@Serisium
Copy link

Seconding @evgentset's fix! Worked for me on coroutines 1.1.1

@dendrocyte
Copy link

I have the same issue. but the link is not available now. Could @evgentset provide again? please

@marlboro3420
Copy link

coroutines.pro @dendrocyte a copy from @evgentset

@ghost
Copy link

ghost commented Apr 30, 2019

@dendrocyte if you are having options for Kotlin in build.gradle packageOptions you can remove them. It will work again without need adding the proguard rule. In my case, I could export file APK but it had the RunTimeException when opening the app so I removed all packageOptions for kotlin and it worked fine with Kotlin 1.3.31 and coroutine 1.2.1

@endru-kargo
Copy link

In our case, we put signingConfigs in the gradle file, then use the Generate Signed Bundle / APK to create the bundle. :D
Removing the signingConfigs solves the problem.

@dendrocyte
Copy link

@endru-kargo I will try your solution later. thank you!!!

@elizarov
Copy link
Contributor

Did it help?

@dendrocyte
Copy link

dendrocyte commented May 16, 2019

my client phone are Samsung and Sharp which are hit this error.
At the end, I upgrade your lib to 1.2.1, and make the error
from
Job = launch{}
change to
Job = launch{} as CompletableJob.
Then it fix!

@RahulSDeshpande
Copy link

I has same issue and fixed it by adding options from coroutines.pro to proguard. Hope it helps somebody.

Correcting the git link 'coroutines.pro'.

@igorwojda
Copy link

For me updating Koltin to 1.3.50 and coroutines to 1.3.2 (having AGP 3.5.1) fixed the issue (I guess that it was initially broken by APG update or Dexguard update)

@jmamath
Copy link

jmamath commented Sep 4, 2020

It was also discussed in issue #1532. Turning kotlin [1.3.50 -> 1.3.61], coroutines [1.3.1 -> 1.3.3] did the work for me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests