The runtime for kotlin was not found when using MultiDex.

because the number of code methods exceeds 65535 and cannot be packaged, I introduced MultiDex subpackages.
when I finished packing, one of the kotlin functions that I ran into the class went wrong, causing the program to crash.
has looked up a lot of information that there is no kotlin runtime, but there was no problem with the program before multidex was introduced.
and I"m sure that MultiDex.install is run before loading the kotlin function that reported the error.

I guess this is because the dex subpackage puts runtime of kotlin into the slave package, and it is not a normal class at run time? So it causes an error

.

I tried to search for this error java.lang.NoClassDefFoundError: Failed resolution of: Lkotlin/jvm/internal/Intrinsics; did not solve the problem by adding a tripartite dependency.

complete error message is as follows

06-11 18:54:39.516 com.morn.liquidate.app I/zygote64: Late-enabling -Xcheck:jni
06-11 18:54:39.633 ? I/MultiDex: VM with version 2.1.0 has multidex support
06-11 18:54:39.633 ? I/MultiDex: Installing application
06-11 18:54:39.633 ? I/MultiDex: VM has multidex support, MultiDex support library is disabled.
06-11 18:54:39.635 ? D/AndroidRuntime: Shutting down VM
06-11 18:54:39.636 ? E/AndroidRuntime: FATAL EXCEPTION: main
                                       Process: com.morn.liquidate.app, PID: 7870
                                       java.lang.NoClassDefFoundError: Failed resolution of: Lkotlin/jvm/internal/Intrinsics;
                                           at core.tool.ToastHelper.init(Unknown Source:2)
                                           at core.base.CoreApplication.onCreate(CoreApplication.kt:21)
                                           at android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:1119)
                                           at android.app.ActivityThread.handleBindApplication(ActivityThread.java:5872)
                                           at android.app.ActivityThread.-wrap1(Unknown Source:0)
                                           at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1689)
                                           at android.os.Handler.dispatchMessage(Handler.java:105)
                                           at android.os.Looper.loop(Looper.java:171)
                                           at android.app.ActivityThread.main(ActivityThread.java:6684)
                                           at java.lang.reflect.Method.invoke(Native Method)
                                           at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:246)
                                           at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:783)
                                        Caused by: java.lang.ClassNotFoundException: Didn"t find class "kotlin.jvm.internal.Intrinsics" on path: DexPathList[[zip file "/data/app/com.morn.liquidate.app-YDKPOrzDjogfCbOyYWMxCA==/base.apk"],nativeLibraryDirectories=[/data/app/com.morn.liquidate.app-YDKPOrzDjogfCbOyYWMxCA==/lib/arm64, /system/lib64, /system/vendor/lib64]]
                                           at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:93)
                                           at java.lang.ClassLoader.loadClass(ClassLoader.java:379)
                                           at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
                                           at core.tool.ToastHelper.init(Unknown Source:2)
                                           at core.base.CoreApplication.onCreate(CoreApplication.kt:21)
                                           at android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:1119)
                                           at android.app.ActivityThread.handleBindApplication(ActivityThread.java:5872)
                                           at android.app.ActivityThread.-wrap1(Unknown Source:0)
                                           at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1689)
                                           at android.os.Handler.dispatchMessage(Handler.java:105)
                                           at android.os.Looper.loop(Looper.java:171)
                                           at android.app.ActivityThread.main(ActivityThread.java:6684)
                                           at java.lang.reflect.Method.invoke(Native Method)
                                           at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:246)
                                           at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:783)
06-11 18:54:39.658 ? I/Process: Sending signal. PID: 7870 SIG: 9

hoping to get some hints.

this is my kotlin dependency

    ext.kotlin_version = "1.1.51"
    api "org.jetbrains.kotlin:kotlin-stdlib-jre7:$kotlin_version"

I guess the reason for the collapse is that the loading of mutlidex also occurs in the kotlin method, which gives rise to the "chicken or egg" problem. As a result, the class could not be found.

Mar.18,2021

I also encountered the solution: rewrite that class with java

Menu