In our recent release of out application we are getting Fatal Exception: java.lang.NoClassDefFoundError: kotlinx.coroutines.CoroutineExceptionHandlerImplKt
more often, The stack-trace says that it didn`t find the class at DexPathList. We were using multidex previously but recently we have added dex-guard in out application and as per dex-guard documentation Multidex is handled by dex-guard. But here the crash is reported and it looks like dex-guard is not handling it properly. Here is complete stacktracke. Any help would be appreciated.
Fatal Exception: java.lang.NoClassDefFoundError: kotlinx.coroutines.CoroutineExceptionHandlerImplKt
at kotlinx.coroutines.CoroutineExceptionHandlerImplKt.handleCoroutineExceptionImpl(:27)
at kotlinx.coroutines.CoroutineExceptionHandlerKt.handleCoroutineException(:33)
at kotlinx.coroutines.DispatchedTask.handleFatalException(:146)
at kotlinx.coroutines.DispatchedTask.run(:115)
at android.os.Handler.handleCallback(Handler.java:907)
at android.os.Handler.dispatchMessage(Handler.java:105)
at android.os.Looper.loop(Looper.java:216)
at android.app.ActivityThread.main(ActivityThread.java:7625)
at java.lang.reflect.Method.invoke(Method.java)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:524)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:987)
Caused by java.util.ServiceConfigurationError: kotlinx.coroutines.CoroutineExceptionHandler: Provider kotlinx.coroutines.android.AndroidExceptionPreHandler not found
at java.util.ServiceLoader.fail(ServiceLoader.java:233)
at java.util.ServiceLoader.access$100(ServiceLoader.java:183)
at java.util.ServiceLoader$LazyIterator.nextService(ServiceLoader.java:373)
at java.util.ServiceLoader$LazyIterator.next(ServiceLoader.java:416)
at java.util.ServiceLoader$1.next(ServiceLoader.java:494)
at kotlin.sequences.SequencesKt___SequencesKt.toCollection(:786)
at kotlin.sequences.SequencesKt___SequencesKt.toMutableList(:816)
at kotlin.sequences.SequencesKt___SequencesKt.toList(:807)
at kotlinx.coroutines.CoroutineExceptionHandlerImplKt.<clinit>(:23)
at kotlinx.coroutines.CoroutineExceptionHandlerImplKt.handleCoroutineExceptionImpl(:27)
at kotlinx.coroutines.CoroutineExceptionHandlerKt.handleCoroutineException(:33)
at kotlinx.coroutines.StandaloneCoroutine.handleJobException(:192)
at kotlinx.coroutines.JobSupport.finalizeFinishingState(:229)
at kotlinx.coroutines.JobSupport.tryMakeCompletingSlowPath(:906)
at kotlinx.coroutines.JobSupport.tryMakeCompleting(:863)
at kotlinx.coroutines.JobSupport.makeCompletingOnce$kotlinx_coroutines_core(:828)
at kotlinx.coroutines.AbstractCoroutine.resumeWith(:100)
at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(:46)
at kotlinx.coroutines.DispatchedTask.run(:106)
at android.os.Handler.handleCallback(Handler.java:907)
at android.os.Handler.dispatchMessage(Handler.java:105)
at android.os.Looper.loop(Looper.java:216)
at android.app.ActivityThread.main(ActivityThread.java:7625)
at java.lang.reflect.Method.invoke(Method.java)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:524)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:987)
Caused by java.lang.ClassNotFoundException: kotlinx.coroutines.android.AndroidExceptionPreHandler
at java.lang.Class.classForName(Class.java)
at java.lang.Class.forName(Class.java:453)
at java.util.ServiceLoader$LazyIterator.nextService(ServiceLoader.java:371)
at java.util.ServiceLoader$LazyIterator.next(ServiceLoader.java:416)
at java.util.ServiceLoader$1.next(ServiceLoader.java:494)
at kotlin.sequences.SequencesKt___SequencesKt.toCollection(:786)
at kotlin.sequences.SequencesKt___SequencesKt.toMutableList(:816)
at kotlin.sequences.SequencesKt___SequencesKt.toList(:807)
at kotlinx.coroutines.CoroutineExceptionHandlerImplKt.<clinit>(:23)
at kotlinx.coroutines.CoroutineExceptionHandlerImplKt.handleCoroutineExceptionImpl(:27)
at kotlinx.coroutines.CoroutineExceptionHandlerKt.handleCoroutineException(:33)
at kotlinx.coroutines.StandaloneCoroutine.handleJobException(:192)
at kotlinx.coroutines.JobSupport.finalizeFinishingState(:229)
at kotlinx.coroutines.JobSupport.tryMakeCompletingSlowPath(:906)
at kotlinx.coroutines.JobSupport.tryMakeCompleting(:863)
at kotlinx.coroutines.JobSupport.makeCompletingOnce$kotlinx_coroutines_core(:828)
at kotlinx.coroutines.AbstractCoroutine.resumeWith(:100)
at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(:46)
at kotlinx.coroutines.DispatchedTask.run(:106)
at android.os.Handler.handleCallback(Handler.java:907)
at android.os.Handler.dispatchMessage(Handler.java:105)
at android.os.Looper.loop(Looper.java:216)
at android.app.ActivityThread.main(ActivityThread.java:7625)
at java.lang.reflect.Method.invoke(Method.java)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:524)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:987)
Caused by java.lang.ClassNotFoundException: Didn't find class "kotlinx.coroutines.android.AndroidExceptionPreHandler" on path: DexPathList[[zip file "/system/framework/org.apache.http.legacy.boot.jar", zip file "/data/app/com.app.appname-dTd-4drfd8YfK38C73N7WQ==/base.apk", zip file "/data/app/com.app.appname-dTd-4drfd8YfK38C73N7WQ==/split_config.armeabi_v7a.apk", zip file "/data/app/com.app.appname-dTd-4drfd8YfK38C73N7WQ==/split_config.xhdpi.apk"],nativeLibraryDirectories=[/data/app/com.app.appname-dTd-4drfd8YfK38C73N7WQ==/lib/arm, /data/app/com.app.appname-dTd-4drfd8YfK38C73N7WQ==/base.apk!/lib/armeabi-v7a, /data/app/com.app.appname-dTd-4drfd8YfK38C73N7WQ==/split_config.armeabi_v7a.apk!/lib/armeabi-v7a, /data/app/com.app.appname-dTd-4drfd8YfK38C73N7WQ==/split_config.xhdpi.apk!/lib/armeabi-v7a, /system/lib, /product/lib]]
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:134)
at java.lang.ClassLoader.loadClass(ClassLoader.java:379)
at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
at java.lang.Class.classForName(Class.java)
at java.lang.Class.forName(Class.java:453)
at java.util.ServiceLoader$LazyIterator.nextService(ServiceLoader.java:371)
at java.util.ServiceLoader$LazyIterator.next(ServiceLoader.java:416)
at java.util.ServiceLoader$1.next(ServiceLoader.java:494)
at kotlin.sequences.SequencesKt___SequencesKt.toCollection(:786)
at kotlin.sequences.SequencesKt___SequencesKt.toMutableList(:816)
at kotlin.sequences.SequencesKt___SequencesKt.toList(:807)
at kotlinx.coroutines.CoroutineExceptionHandlerImplKt.<clinit>(:23)
at kotlinx.coroutines.CoroutineExceptionHandlerImplKt.handleCoroutineExceptionImpl(:27)
at kotlinx.coroutines.CoroutineExceptionHandlerKt.handleCoroutineException(:33)
at kotlinx.coroutines.StandaloneCoroutine.handleJobException(:192)
at kotlinx.coroutines.JobSupport.finalizeFinishingState(:229)
at kotlinx.coroutines.JobSupport.tryMakeCompletingSlowPath(:906)
at kotlinx.coroutines.JobSupport.tryMakeCompleting(:863)
at kotlinx.coroutines.JobSupport.makeCompletingOnce$kotlinx_coroutines_core(:828)
at kotlinx.coroutines.AbstractCoroutine.resumeWith(:100)
at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(:46)
at kotlinx.coroutines.DispatchedTask.run(:106)
at android.os.Handler.handleCallback(Handler.java:907)
at android.os.Handler.dispatchMessage(Handler.java:105)
at android.os.Looper.loop(Looper.java:216)
at android.app.ActivityThread.main(ActivityThread.java:7625)
at java.lang.reflect.Method.invoke(Method.java)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:524)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:987)