Javadoc error: "option --boot-class-path not allowed with target 11"

Javadoc error: "option --boot-class-path not allowed with target 11"

我使用 JDK 11 和 Android SDK 28 在 Intellij 中编写了一个功能齐全的 Android 应用程序。但是我无法 运行 我的代码中的 JavaDoc ,我不知道为什么或如何解决它!起初,我遇到了很多错误,例如 "android.whatever package not found"。修复起来很简单,谷歌搜索后我发现我需要将 -bootclasspath pathtomyandroidsdkjarfile 添加到 "extra command line options" 部分,这为其他人解决了这个问题。但是当我添加该行时,出现以下错误:

error: option --boot-class-path not allowed with target 11

我不确定 "target 11" 是什么意思,但我想我可以推断出它的意思是 JDK 11。所以,我不知道该从哪里开始。任何人都可以提供的任何帮助将不胜感激!

所以在随机尝试了一堆变体之后,我想我已经解决了。似乎在 JDK 10+ 中,-bootclasspath 参数已被弃用,并已与 -sourcepath 参数一起使用。因此,通过将 -sourcepath pathtomyandroidsdkjarfile 放在 "Extra command line options" 部分,我设法解决了这个问题。

这可能是因为您没有按照建议使用 embedded JDK

official doc 说:

Set the JDK version

A copy of the latest OpenJDK comes bundled with Android Studio 2.2 and higher, and this is the JDK version we recommend you use for your Android projects. To use the bundled JDK, do the following:

  1. Open your project in Android Studio and select File > Project Structure in the menu bar.
  2. In the SDK Location page and under JDK location, check the Use embedded JDK checkbox.
  3. Click OK.

我遇到了同样的问题,切换到嵌入式版本确实解决了。