重构几个模块(移动一些东西)后出现编译错误:
e: Could not load module <Error module>
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:kaptGenerateStubsMyIapKotlin'.
> A failure occurred while executing org.jetbrains.kotlin.compilerRunner.GradleCompilerRunnerWithWorkers$GradleKotlinCompilerWorkAction
> Compilation error. See log for more details
* Try:
> Run with --stacktrace option to get the stack trace.
> Run with --info or --debug option to get more log output.
* Get more help at https://help.gradle.org
BUILD FAILED in 1m 54s
e: Could not load module <Error module>
Flag is not supported by this version of the compiler: -Xuse-experimental=kotlin.Experimental
所以,据我了解,问题是这个标志
-Xuse-experimental=kotlin.Experimental
应该在某些模块中使用?我看到应用程序中的一个模块在 gradle 中使用了这个标志:
tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile).all {
kotlinOptions.freeCompilerArgs += ["-Xuse-experimental=kotlin.Experimental", '-Xjvm-default=all-compatibility']
}
因此,我已将相同的内容添加到我的新模块中,并添加了另一个已更改的模块,但仍然发生此错误。
如何了解问题所在?如何正确调试这个问题?任何建议表示赞赏。
对于编译器标志
-Xuse-experimental
你的错误说:
Flag is not supported by this version of the compiler
因此,我建议您从所有存在的构建脚本中删除它,而不是添加它。
此选项已在 v1.5.30 中被弃用。与此一致,我发现它仅在与当前 (v1.9.23) 版本的 Kotlin 一起使用时才会发出警告,因此我认为您将警告视为一个或多个 Gradle 脚本的错误。