Wednesday, February 02, 2011

Losing Javadocs in Eclipse: SOLUTION

Occasionally and for reasons that I do not fully understand, Eclipse may lose track of your Javadocs. That means, when you mouse over an Android API call expecting to read about it, you'll get the dreaded "This element has no attached source and the Javadoc could not be found in the attached Javadoc" error message.

The traditional method to solving this issue is to delete the eclipse .metadata directory. This does in fact work (I tried it) but it also requires you to redownload and setup the Android ADT...plus you lose ALL of your eclipse settings and preferences. If you're like me and have custom fonts and syntax highlighting setup, then that's a nuisance.

The "right way" (and by right way I mean "this worked for me and i didn't lose data) to solve this problem is to follow these instructions:

  1. In eclipse, right click on your Android project and select Properties
  2. On the menu on the left, select "Java Build Path"
  3. On the right hand side, select the "tab" labelled "Libraries".
  4. Here you should see the Android SDK that you're targeting. For example: "Android 2.2".
  5. Click on the arrow to the left of the Android SDK to expand the sublevels.
  6. Find "Android.jar" and click on the arrow to the left of that one as well to expand it.
  7. You'll see a setting called "Javadoc location". Select that and then click on the "Edit" button.
  8. At the top, RESELECT the path to your javadocs. This is usually "path_to_android_sdk/android-sdk-mac_86/docs/reference/". I say RESELECT because even if it's right, you should browse and do it over anyway.
  9. Click on "validate". You should be all set now!

8 comments: