I get a null pointer exception opening about half of the android XML files in my layout directory. There seems to be no pattern to why some files open and some files don't.
I upgraded eclipse to Juno. Re-installed all the plugins (ADT), re-installed the android SDK. I brought in my old workspace and adjusted my projects to point at the new android SDK.
Stack
java.lang.NullPointerException
at com.android.ide.eclipse.adt.internal.editors.layout.configuration.ConfigurationComposite.setLocaleCombo(ConfigurationComposite.java:1566)
at com.android.ide.eclipse.adt.internal.editors.layout.configuration.ConfigurationComposite.syncRenderState(ConfigurationComposite.java:3049)
at com.android.ide.eclipse.adt.internal.editors.layout.gle2.GraphicalEditorPart.activated(GraphicalEditorPart.java:1158)
at com.android.ide.eclipse.adt.internal.editors.layout.LayoutEditorDelegate.delegatePageChange(LayoutEditorDelegate.java:679)
at com.android.ide.eclipse.adt.internal.editors.common.CommonXmlEditor.pageChange(CommonXmlEditor.java:359)
at org.eclipse.ui.part.MultiPageEditorPart.setActivePage(MultiPageEditorPart.java:1081)
at org.eclipse.ui.forms.editor.FormEditor.setActivePage(FormEditor.java:607)
I found one way to resolve this. My eclipse recently crashed (and wouldn't start again) for an unrelated reason. To get it to start again I deleted most of the files in ${workspace}/.metadata/.plugins. These files regenerate (but will wipe some of your saved plugins and settings). Resolved my startup problem and my xml editor problem.
Just close all the xml files and restart your Eclipse SDK
An additional solution that worked for me and might work for others:
Create a new workspace and import your existing projects into it. I felt a little better about trying this than I did blowing away or moving my .plugins directory in the existing workspace. After I created the new workspace and imported the project that was giving me the cryptic "Failed to create parts controls" message, it worked fine. I'm pretty sure it's something bad in the .plugins or elsewhere in the old workspace, but I'll just keep using this new one until it starts to crap out on me.
Note that this can also happen if the containing folder contains too high a resolution
Example:
layout-sw500dp (this folder works okay)
layout-sw1000dp (this folder causes "Failed to create the part's controls" error)
I finally found out...
I had the problem even after deleting and setting a new copy of eclipse. The problem was because of the wrong Java version. You should find the right Java version for your eclipse.
In my case I have a project which uses Java 8 and for that I use eclipse Luna. But my other project which I develop it vie eclipse kepler uses java 6 (The project with the problem!).
Since Kepler and Java 8 are not compatible, I got this weird behavior from kepler. As soon as I ran Kepler via Java 6, everything was back to normal.
If you wanna know how to sets different Environment Variables and sets your Windows Path without setting up the Environment variable everytime for each project, let me know, I would be happy to share how to write a batch file to do that...