Android + Kotlin构建错误:Kotlin主页不存在或不是目录 [英] Android + Kotlin build error: Kotlin home does not exist or is not a directory

查看:352
本文介绍了Android + Kotlin构建错误:Kotlin主页不存在或不是目录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有时候我在尝试编译我的Android应用时收到此错误:
e:Kotlin主页不存在或不是目录:
失败:生成失败,发生异常.

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.

发生在命令行(./gradlew clean build)和Android Studio 3.0.1中.我已经完成了File-> Invalidate Caches/Restart,但这并不能解决问题.

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.

我的所有Kotlin src都在src/main/java下,因为大多数代码仍然是java.

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"

更新
发现问题的原因.我在不同版本的Kotlin上有多个Android应用程序.如果我构建一个应用程序,则打开另一个应用程序并尝试构建它-kaboom! KotlinCompileDaemon和GradleDaemon进程仅特定于一个Kotlin版本.解决方案是杀死KotlinCompileDaemon和GradleDaemon的那些进程.您可以使用如下所述的"killall java",但这会杀死所有您可能不需要的Java进程.

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.

推荐答案

您可以尝试两种方法:

  1. 清理您的Android Studio缓存并重新启动.

  1. Clean your Android studio cache and restart.

杀死 KotlinCompileDaemon GradleDaemon 进程并重新启动gradle:

Kill KotlinCompileDaemon and GradleDaemon processes and restart gradle:

kill KotlinCompileDaemon
kill GradleDaemon
./gradlew clean assemble

我希望这可以帮助,如果不能随意发表评论:)

I hope this helps if not feel free to post a comment :)

这篇关于Android + Kotlin构建错误:Kotlin主页不存在或不是目录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆