Javadoc in Eclipse failing to recognize packages
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 converted into a link to "http://d.android.com/reference/android/widget/Toast.html?is-external=true". I achieved this with the Javadoc option:
-linkoffline http://d.android.com/reference "file:/C:/Android/android-sdk-windows/docs/reference"
However, I get errors such as the following based on lines of my Java code (not the Javadoc comments):
C:\Users\Ellen\workspace\TestableToast\src\edu\mills\cs180\HelloAndroid.java:5: package android.view does not exist import android.view.View; ^ C:\Users\Ellen\workspace\TestableToast\src\edu\mills\cs180\HelloAndroid.java:6: package android.view.View does not exist import android.view.View.OnClickListener; ^ C:\Users\Ellen\workspace\TestableToast\src\edu\mills\cs180\HelloAndroid.java:8: package android.widget does not exist import android.widget.Toast; ^ C:\Users\Ellen\workspace\TestableToast\src\edu\mills\cs180\HelloAndroid.java:10: cannot find symbol symbol: class Activity public class HelloAndroid extends Activity implements OnClickListener { ^
How can I fix these references?
Solution 1:
This Works in Eclipse for me:
- Project --> generate Javadoc
- Go to "Configure Javadoc arguments."
- in VM options add "-bootclasspath /path/to/sdk/platforms/android-##/android.jar"
Solution 2:
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 ajavadoc.sh
shell script.
Solution 3:
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.