Sometimes I get this error when trying to compile my Android app:
e: Kotlin home does not exist or is not a directory:
FAILURE: Build failed with an exception.
Happens at command line (./gradlew clean build) and in Android Studio 3.0.1. I have done File -> Invalidate Caches / Restart, that does not fix it.
All my Kotlin src is under src/main/java since the majority of the code is still java.
interesting versions / plugins /dependencies:
ext.kotlinVersion = '1.2.21'
classpath 'com.android.tools.build:gradle:3.0.1'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlinVersion"
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-kapt'
compileSdkVersion 26
buildToolsVersion "26.0.3"
targetSdkVersion 26
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlinVersion"
UPDATE
Found cause of problem. I have multiple Android apps, on different versions of Kotlin. If I build one app, then open another app and try to build it -- kaboom! KotlinCompileDaemon and GradleDaemon processes are specific to just one Kotlin version. The solution is to kill those processes for KotlinCompileDaemon and GradleDaemon. You could use "killall java" as mentioned below, but that kills all of your java processes, which you may not want.