我希望能够通过命令行编译我的应用程序,而不是通过Android Studio进行编译。 当我通过Android Studio将应用程序启动到设备/模拟器上时,它可以完美地工作,但是当我尝试通过以下方式进行编译时:
gradlew build
I get :
> Task :app:kaptGenerateStubsReleaseKotlin FAILED
Caught an exception trying to connect to Kotlin Daemon
org.gradle.api.GradleException: Kotlin could not find the required JDK tools in the Java installation 'C:\Program Files (x86)\Java\jre1.8.0_191' used by Gradle. Make sure Gradle is running on a JDK, not JRE.
at org.jetbrains.kotlin.gradle.tasks.JarSearchingUtilKt.findToolsJar(jarSearchingUtil.kt:95)
at org.jetbrains.kotlin.compilerRunner.GradleCompilerEnvironment$toolsJar$2.invoke(GradleCompilerEnvironment.kt:23)
at org.jetbrains.kotlin.compilerRunner.GradleCompilerEnvironment$toolsJar$2.invoke(GradleCompilerEnvironment.kt:17)
at kotlin.SynchronizedLazyImpl.getValue(Lazy.kt:131)
...
这是我的JAVA_HOME环境变量:
JAVA_HOME=C:\Program Files (x86)\Java\jre1.8.0_191
实际上这是JRE(而不是JDK),但是,当我将我的环境变量更改为以下的JDK:
JAVA_HOME=C:\Program Files\Java\jdk-11.0.1
我启动:
gradlew build
然后我得到:
FAILURE: Build failed with an exception.
* What went wrong:
Could not determine java version from '11.0.1'.
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
* Get more help at https://help.gradle.org