Javadoc in Eclipse failing to recognize packages

前端 未结 8 1472
傲寒
傲寒 2020-11-27 15:23

Thanks to this thread, I was able to get Javadoc links to work for my Android project within Eclipse on Windows. Specifically, \"{@link android.widget.Toast}\" is currently

相关标签:
8条回答
  • 2020-11-27 15:44

    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.
    0 讨论(0)
  • 2020-11-27 15:51

    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.

    0 讨论(0)
  • 2020-11-27 15:52

    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 :)

    0 讨论(0)
  • 2020-11-27 15:56

    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
    0 讨论(0)
  • 2020-11-27 16:03

    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.

    0 讨论(0)
  • 2020-11-27 16:06

    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"
    

    JavaDoc generation screen on Android Studio

    0 讨论(0)
提交回复
热议问题