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

Viewed 6663

I have written a fully functional Android app in Intellij, using JDK 11 and Android SDK 28. But I am unable to run JavaDoc on my code, and I can't figure out why or how to fix it! At first, I was getting many errors such as "android.whatever package not found". Simple enough to fix, after googling I found I need to add -bootclasspath pathtomyandroidsdkjarfile to the "extra command line options" section, and that fixes the problem for everyone else. But when I add that line, I get the following error:

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

I'm not sure what "target 11" means, but I think I can infer it means the JDK 11. So, I've got no idea where to go from here. Any help anyone can provide would be greatly appreciated!

2 Answers

So after trying a bunch of variations at random, I think I've solved it. It seems like in JDK 10+ the -bootclasspath argument has been deprecated, and has been rolled in together with the -sourcepath argument. So by putting -sourcepath pathtomyandroidsdkjarfile in the "Extra command line options" section, I managed to fix the issue.

It might be because you were not using the embedded JDK as is advised:

The official doc says:

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.

I had the same issue and switching to the embedded version did indeed solve it.

Related