Very annoying crash : java.lang.NoClassDefFoundError: Failed resolution of: <KotlinObject>


Not sure if this is the right place to ask this but here goes,

Every second run of our android app, we get a crash that says

java.lang.NoClassDefFoundError: Failed resolution of: Lin/blahapp/xxx/BlahUtil
BlahUtil is a kotlin object with @JvmStatic annotations in it. I call these static methods from the rest of the android app(All in java) .

We use multidex 1.0.1.

I am on android studio 2.1.2, using JDK 7.

Relevant gradle configs:

compileSdkVersion 23
buildToolsVersion "23.0.3"
defaultConfig {
        minSdkVersion 16
        targetSdkVersion 23
dexOptions {
        incremental true
        dexInProcess true
        javaMaxHeapSize "10g"
        preDexLibraries true
buildscript {
    ext.kotlin_version = '1.0.3'

    dependencies {
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
apply plugin: 'kotlin-android'
dependencies {
  compile "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
  compile "org.jetbrains.kotlin:kotlin-reflect:$kotlin_version"


at android.os.Handler.dispatchMessage(
at android.os.Looper.loop(
at java.lang.reflect.Method.invoke(Native Method)
Caused by: java.lang.ClassNotFoundException: Didn't find class "" on path: DexPathList[[dex file ....




I could not reproduce your issue.
Am I right that by “every second run” you mean subsequent runs of Android Emulator?
Could you try to create a reproducible example project?


I seem to have the same problem. It started happening after upgrading Android Build Tools from 2.1.2 to 2.1.3. This also forced me to upgrade Gradle from 2.10 to 2.14.1. I’m using multidex, multiple build flavors and am building on Windows atm.

It seems it is not just @JvmStatic, but all Kotlin classes (.kt) are not available.

free is one of the build flavors. The classes are not in build\intermediates\classes\free\debug, but I have found them in build\tmp\kotlin-classes\freeDebug. I think this was the case before the upgrade as well.

I tried to get the classes from the apk using dex2jar, but that resulted in an error and not all classes were exported. What tool would you suggest to check whether the class is actually in the apk? Or should I check something else to find the actual problem?


I upgraded to android studio 2.2 beta 2 and kotlin 1.0.4-eap-62 . things are working now. Even instant run . Wooohooo!


I believe I have similar issue with AS 2.3.1, gradle 3.3 and Kotlin 1.1.1.
The issue happens only on my windows machine. At work I use a mac and it works. My friends tried to reproduce it on his windows machine and he couldn’t.
All the project features (a lot of them) work properly and the app crashes only in one place.

I get:
java.lang.NoClassDefFoundError: com/project/name/SomeActivityKt$sam$Action1$22181393

For this code:

private fun getDataFor(id: String) {

            .map { response -> response.toSomethingList() }
      "Something list fetched ${it.size}")

            }, defaultOnError("Fetching something list failed"))

The defaultOnError function is:

fun <T> T.defaultOnError(message: String, vararg args: Any?): (Throwable) -> Unit where T : HasErrorHandler, T : Activity {
    val targetClass = javaClass
    val activity = this
    return { err ->
        val messageFormats = (args.toList() + err).toTypedArray()
        LoggerFactory.getLogger(targetClass).error(message, *messageFormats)
        errorHandler.default(err, activity)

This function works in other activities but this one. Also, as I said, it works on a mac and on a friends machine.
If I remove this defaultOnError from subscribe it works OK.

Any ideas?


I seem to have the same problem.My environment is Android Studio3.0 canary3 ,Android Build Tools 2.2.3,gradle 3.5 and i`m also using multidex.
the below is the log:
Caused by: java.lang.ClassNotFoundException: Didn’t find class “com.touguyun.activity.AboutUsActivity” on path: DexPathList[[zip file “/data/app/com.touguyun-2/base.apk”],nativeLibraryDirectories=[/data/app/com.touguyun-2/lib/x86, /system/fake-libs, /data/app/com.touguyun-2/base.apk!/lib/x86, /system/lib, /vendor/lib]]
at dalvik.system.BaseDexClassLoader.findClass(
at java.lang.ClassLoader.loadClass(
at java.lang.ClassLoader.loadClass(
at com.touguyun.activity.SetUpActivity.set_up_about_us(
at com.touguyun.activity.SetUpActivity_$2.onClick(
at android.view.View.performClick(
at android.view.View$
at android.os.Handler.handleCallback(
at android.os.Handler.dispatchMessage(
at android.os.Looper.loop(
at java.lang.reflect.Method.invoke(Native Method)