Tuesday, July 28, 2009

When "Eclipse loading framework information into layout resource editor" Fails

The Android Development Plug-in for Eclipse is a great tool many Android developers rely upon. I personally use some features much more than others. For example, I rarely use the Layout Resource editor to preview layout files. Instead, I just edit the XML directly and run it in the Emulator. (I have also been known to edit HTML with notepad, that's just how I roll.)

So it came as a bit of a surprise (read: annoyance) when I tried to do just that--preview a layout file in Eclipse--the other day and it failed. Eclipse seemed to try to load the layout designer saying, "Eclipse is loading framework information and the Layout library from the SDK folder." Then it up and failed to load it. Over and over. You couldn't see the layout preview, nor the Properties pane or the Outline mode to add new controls to the layout tree.

You might be wondering why I bothered to investigate this since I could have just gone back to the XML and blown it off. Well, I needed a screenshot of the Layout preview mode for our new book. Nuff said.

At first, I thought it was just me overestimating the tool's abilities, trying to preview a layout that was too complex for the preview (this happens often when I include some of the more complex View controls in layouts). So I created a new project with its simple default layout file, and that didn't load either. So that wasn't it.

I did a quick search on the Android developer forums and a couple people were complaining on the forums about this over a year ago. One person suggested recreating your workspace. Well, that didn't work, either. I widened my search to the web and ran across a little note on Brian Klug's wiki, suggesting that the older versions of the Android plug-in JAR files might be hanging around, mucking things up. Thanks, Brian! This sent me in the right direction.

We've had a number of new revisions of Android lately. which have improved (greatly) the Android tool chain, that have had several new JAR file updates. Next, I had to find the android JAR files on my machine. First, I checked where Brian had suggested: c:\eclipse\plugins (basically, in the plugins directory of the eclipse installation path). As my luck would have it, they were not there. Instead, a quick file search for "com.android*.jar" showed that they were hiding in C:\Users\YourUserName\.eclipse\org.eclipse.platform_3.4.0_867647348\features.

With a little investigation, I found several older versions (0.8.x and 0.9.0) of the android JAR files installed with the new ones (0.9.1 is the latest for Android SDK 1.5 r3). I shut down Eclipse, deleted all the older JAR files, leaving only the 0.9.1 versions.
Specifically, I only kept these two android JAR files:
  • com.android.ide.eclipse.adt_0.9.1.v200905011822-1621
  • com.android.ide.eclipse.ddms_0.9.1.v200905011822-1621
When I relaunched Eclipse, the layout preview began to function again. Incidentally, this was on a Windows installation of the Android tools. When I checked the Mac install of Android 1.5 R3, the JAR files were hanging about in (rather than the expected /Developer/Applications/eclipse/plugins~/.eclipse), but the layout preview did load without issue.

8 comments:

mehul said...

Thanks dear,

It really help full to me!!!

i was trying to solve that problem since 2 days,

but now i got your help!!

thanks once again!!!

Conrad Braam said...

I am working though the Android in 24-hours book, and it shows a property sheet on the right of the layout? I cannot see one in mine. Is there a menu/hotkey?

Unknown said...

Hi Zaphodikus,

Can you be more specific as to where you are seeing this in the book? (e.g. what page)

I want to make sure I understand your question.

Thanks,

-Shane

Conrad Braam said...

There is a helpfull screenshot of the layout editor Hour 4, in figure 4.2
But I did find my remedy, I had to right-click on the file in the explorer, and select "Show in.../Properties". Hotkey is Alt-Shift-W , I must have closed it earlier to de-clutter but then struggled to find it in the menu.

Unknown said...

Hi Zaphodikus,

Great! I'm glad you found the solution. Thanks for posting it, too. You probably aren't the only one to have run across that issue.

Best,

-Shane

roan.dua@facebook.com said...
This comment has been removed by the author.
roan.dua@facebook.com said...

Hello sir,
I am having problems with my main.xml graphical layout...
the black screen does not show up
instead it says
"Eclipse is unable to load the framework information and the layout library"

roan.dua@facebook.com said...

com.android.ide.eclipse.hierarchyviewer_8.0.1.v201012062107-82219

MANIFEST.imf

should i delete these files also??