Skip to content
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

IllegalStateException: Module with the Main dispatcher is missing #799

Closed
trashkalmar opened this issue Nov 6, 2018 · 15 comments
Closed

IllegalStateException: Module with the Main dispatcher is missing #799

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

Comments

@trashkalmar
Copy link

@trashkalmar trashkalmar commented Nov 6, 2018

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

This comment has been minimized.

Copy link
Author

@trashkalmar trashkalmar commented Nov 6, 2018

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

This comment has been minimized.

Copy link

@Arayldan Arayldan commented Nov 8, 2018

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

@kimcy929

This comment has been minimized.

Copy link

@kimcy929 kimcy929 commented Nov 12, 2018

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

@evgentset

This comment has been minimized.

Copy link

@evgentset evgentset commented Nov 23, 2018

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

@marlboro3420

This comment has been minimized.

Copy link

@marlboro3420 marlboro3420 commented Dec 29, 2018

@evgentset thanks, worked for me. coroutines version 1.0.1

@Serisium

This comment has been minimized.

Copy link

@Serisium Serisium commented Feb 13, 2019

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

@dendrocyte

This comment has been minimized.

Copy link

@dendrocyte dendrocyte commented Apr 30, 2019

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

@marlboro3420

This comment has been minimized.

Copy link

@marlboro3420 marlboro3420 commented Apr 30, 2019

coroutines.pro @dendrocyte a copy from @evgentset

@kimcy929

This comment has been minimized.

Copy link

@kimcy929 kimcy929 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

This comment has been minimized.

Copy link

@endru-kargo endru-kargo commented May 13, 2019

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

This comment has been minimized.

Copy link

@dendrocyte dendrocyte commented May 13, 2019

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

@elizarov

This comment has been minimized.

Copy link
Member

@elizarov elizarov commented May 15, 2019

Did it help?

@elizarov elizarov added the question label May 15, 2019
@dendrocyte

This comment has been minimized.

Copy link

@dendrocyte 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

This comment has been minimized.

Copy link

@RahulSDeshpande RahulSDeshpande commented May 16, 2019

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'.

@elizarov elizarov closed this May 24, 2019
@igorwojda

This comment has been minimized.

Copy link

@igorwojda igorwojda commented Oct 21, 2019

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)

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

Successfully merging a pull request may close this issue.

None yet
You can’t perform that action at this time.