Javadoc in Eclipse failing to recognize packages

浪子不回头ぞ 提交于 2019-11-26 20:01:53
Marcel D-B

This Works in Eclipse for me:

  1. Project --> generate Javadoc
  2. Go to "Configure Javadoc arguments."
  3. in VM options add "-bootclasspath /path/to/sdk/platforms/android-##/android.jar"

Adding -classpath parameter in the last screen of "Generate Javadoc..." wizard did not work for me: I got an error message saying that -classpath parameter can only be specified once.

Not really a solution, but a workaround:

  • In the "Generate Javadoc..." wizard, check the option "Save the settings of this Javadoc export as an Ant script". This generates javadoc.xml file in project directory
  • Edit javadoc.xml file and edit classpath attribute. Specifically, add "/path/to/sdk/platforms/android-##/android.jar" there and any other jars that you get warning messages about
  • Generate the javadoc with: ant -buildfile javadoc.xml. For convenience, I put this line in a javadoc.sh shell script.

You need to put the android classes in your javadoc classpath, too. For this, add the android jar file to the -classpath argument of javadoc (as you would do for your compiler).

I have no idea whether and where Eclipse gives you some configuration option for this, though.

Pushpan

Project > generate Javadoc. Then, go to "Configure Javadoc arguments" and in VM options add "-bootclasspath /path/to/sdk/platforms/android-##/android.jar".

Worked for me :)

Thanks to answer provided by @PaŭloEbermann and @MarcelD-B, I was able to understand the root cause of the issue. However, since I am using Android Studio, I was bit confused as to where to add the argument. After some time, I was able to figure it out finally and I am putting it as an answer here for any other person who finds the similar issue.

For Android Studio, open Tools > Generate JavaDocs and add the following argument in Other command line arguments:-

-bootclasspath /path/to/sdk/platforms/android-##/android.jar

Note:- There's no need of adding any commas in the argument. However, if your SDK Path contains spaces then enclose the path in double quotes ("). eg- My SDK Path contains spaces so I used the argument-

-bootclasspath "F:\Android SDK\platforms\android-21\android.jar"

the answers above are quite good! include the classpath in your javadoc.xml and run is via ant-command or eclipse -> Run As -> Ant Build

BUT be sure that there are no whitespaces in the paths! I had this problems with C:/Program Files/... and it didn't work till i changed it to C:/Progra~1/...

also putting the path in quotes didn't work for me.

Windows Eclipse solution

Adding the android.jar to -classpath is indeed the correct approach. No ANT is necessary, though also viable. In case you want to be using Eclipse GUI (File->Export->Java->Javadoc) for generating Javadoc, there's no option to edit classpath in the dialog. You need to have the classpath set correctly beforehand. Two ways to achieve that:

  1. Edit manually the <path_to_your_project>/.classpath and add the following line:

    <classpathentry kind="lib" path="<path_to_your_android_skd>/platforms/android-<version>/android.jar"/>
    
  2. Right click on your project->Properties->Java Build Path->Libraries->Add External JARs->navigate to <path_to_your_android_skd>/platforms/android-<version>/android.jar

I found the Eclipse GUI approach better than using ANT hinted in some of the answers here because you get clickable references to your source code on any Javadoc warning/error in Console. When using ANT all you get in Console is printed output of the javadoc.exe command.

This workaround in eclipse worked for me:

  1. Go to Project=>Properties and select "Java Build Path"
  2. Select "Order and Export" tab
  3. Move "android 2.x.x" and "Android Dependencies" to the top of the list
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!