Home > android, tools > Fixing slow code assist for Android in Eclipse Helios – update 2 (and getting Android sources into Eclipse, too!)

Fixing slow code assist for Android in Eclipse Helios – update 2 (and getting Android sources into Eclipse, too!)

As you can see from my previous posts, getting code assist to work well for Android projects in Eclipse Helios can be done in one of two ways. You can either uninstall Android JavaDoc package and lose method and parameter descriptions in code assist, or install a patched eclipse JDT plugin.

There is a third way, and you get Android sources for easy referencing and debugging too. Best thing, it’s really simple and only takes three steps.

Update January 29, 2011: make sure to also check out this post, which shows how to build with one version of Android and debug with sources for another.

1 – Get Android framework sources

If you don’t build Andorid system images, and don’t have Git and repo tool, get the sources from http://android.git.kernel.org as a tarball.

This is the framework tarball for Froyo (108 Megabytes):

http://android.git.kernel.org/?p=platform/frameworks/base.git;a=snapshot;h=froyo;sf=tgz

You can get other versions by changing the tag (froyo) in the link above (to donut, gingerbread, etc.)

2 – Extract a portion of the tarball into the right place

Eclipse wants sources in the right place, organized by package name, the same way the source code for your project is organized.

That right place is a “sources” directory that you should create under your android-sdk-windows\platforms\android-VERSION.

Open the tarball with your favorite program (I use WinRar) and navigate to core\java inside it. You will see a directory called “android”, which looks like this:

Now you need to extract the “android” folder inside the tarball into android-sdk-windows\platforms\android-VERSION\sources, so you get this:

3 – Verify the settings for Android.jar and hit refresh

Right click on android.jar in your project, and verify the location path:

After closing this dialog, refresh your project (press F5 in the project explorer or right-click on your project and choose Refresh).

And this is what we get from doing the above

JavaDoc in code assist

The ability to view Android framework sources right from Eclipse

… which also works in the debugger

And that’s it. With many thanks to http://android.opensourceror.org/2010/01/18/android-source/

Advertisements
Categories: android, tools
  1. Jack
    August 12, 2011 at 11:06 pm

    Just to let people know, the Sources Plugin DOES NOT WORK, source files are out of date, resulting in misaligned source while debugging.

    • August 12, 2011 at 11:48 pm

      I never bothered to download it, prefering to get the sources for my device directly from the repo. However, I do know that Peco recently updated the plugin to include more Android versions.

  2. Haris Peco
    January 30, 2011 at 5:58 pm
    • January 30, 2011 at 6:05 pm

      Interesting, thanks.

      The good thing is that the JavaDoc slowness issue has been accepted for Eclipse 3.6SR2.

  3. January 30, 2011 at 9:42 am

    This works for me. I’m glad that you’ve posted this solution in plain English so I can understand it.
    It works nice. Now I like programming my Android apps even more.

    Many thanks, and regards from Amsterdam,
    Bikkel.

  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s