본문 바로가기
프로그래밍 놀이터/Kotlin, Coroutine

[coroutine] java.lang.IllegalStateException: Module with the Main dispatcher is missing. Add dependency providing the Main dispatcher, e.g. 'kotlinx-coroutines-android'

by 돼지왕 왕돼지 2019. 3. 6.
반응형

[coroutine] java.lang.IllegalStateException: Module with the Main dispatcher is missing. Add dependency providing the Main dispatcher, e.g. 'kotlinx-coroutines-android'


coroutine build error, coroutine illegalstateexecption, coroutine minify, coroutine proguard, e.g. 'kotlinx-coroutines-android', [coroutine] java.lang.IllegalStateException: Module with the Main dispatcher is missing. Add dependency providing the Main dispatcher


-

coroutine 을 사용한 project 에서 release build (minify 포함) 을 하면 아래와 같은 exception 이 발생하며 crash 가 발생한다.

java.lang.IllegalStateException: Module with the Main dispatcher is missing. Add dependency providing the Main dispatcher, e.g. 'kotlinx-coroutines-android’



-

범인은 바로 proguard.

proguard 파일은 version 에 따라 바뀔지 모르지만, 아래 링크를 참조하면 최신정보를 계속 얻을 수 있지 않을까 싶다.

https://github.com/Kotlin/kotlinx.coroutines/blob/master/ui/kotlinx-coroutines-android/example-app/app/proguard-rules.pro


내용은...

-keepnames class kotlinx.coroutines.internal.MainDispatcherFactory {} 
-keepnames class kotlinx.coroutines.CoroutineExceptionHandler {} 
-keepclassmembernames class kotlinx.** { 
    volatile <fields>; 
}


-

proguard 적용해주고 하니 잘 작동한다.

고민 해결!!





반응형

댓글