ClassNotFoundException in custom flavor using kotlin

This is a bug in kotlin-gradle plugin for Android and it will be fixed in 0.9.488 or higher.


In my case, I forgot apply plugin: 'kotlin-android' in the gradle file. Although my project was built successfully, it throw java.lang.ClassNotFoundException at runtime. I'm using Kotlin 1.1.1


Try adding both to main.java.srcDirs because you want them both to compile yes?

sourceSets {    
    main.java.srcDirs += 'src/main/kotlin'         
    main.java.srcDirs += 'src/myflavor/kotlin'   
}