I have recently installed Eclipse IDE for Java Developers (Version: 3.6.1) with the Android SDK Platform 2.1update1 - on Windows 7.
I can add, edit and run code for projects, however, in the Workbench area the Graphical Layout view of the layout xml files always shows a "missing theme" message in bottom right navigation area.The left Palette navigator area is ok and the remaining area is blank.
The error message reads: "Selecting page '0' in AndroidXmlEditor failed"
The first and last 10 lines from the Exception Stack Trace reads:
java.lang.NullPointerException
at com.android.ide.eclipse.adt.internal.editors.layout.gle2.Gra phicalEditorPart.renderWithBridge(Unknown Source)
at com.android.ide.eclipse.adt.internal.editor开发者_如何学Pythons.layout.gle2.Gra phicalEditorPart.recomputeLayout(Unknown Source)
at com.android.ide.eclipse.adt.internal.editors.layout.gle2.Gra phicalEditorPart.activated(Unknown Source)
at com.android.ide.eclipse.adt.internal.editors.layout.LayoutEd itor.pageChange(Unknown Source)
at org.eclipse.ui.part.MultiPageEditorPart.setActivePage(MultiP ageEditorPart.java:1067)
at org.eclipse.ui.forms.editor.FormEditor.setActivePage(FormEdi tor.java:607)
at com.android.ide.eclipse.adt.internal.editors.AndroidXmlEdito r.selectDefaultPage(Unknown Source)
at com.android.ide.eclipse.adt.internal.editors.AndroidXmlEdito r.addPages(Unknown Source)
at org.eclipse.ui.forms.editor.FormEditor.createPages(FormEdito r.java:138)
at org.eclipse.ui.part.MultiPageEditorPart.createPartControl(Mu ltiPageEditorPart.java:348)
at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher .start(EclipseAppLauncher.java:79)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseS tarter.java:369)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseS tarter.java:179)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java: 619)
at org.eclipse.equinox.launcher.Main.basicRun(Main.java:574)
at org.eclipse.equinox.launcher.Main.run(Main.java:1407)
Thanks for your help in advance.
In the "Graphical Layout" tab of the layout editor there is a dropdown for selecting the Android version to use. In your case it is probably blank, so select a version and you're probably good to go.
You just select theme on top. above You can see your xml design on my image:
I had the same issue. I solved it by adding a theme attribute to the Android manifest file. I needed a single theme for all the Activities hence I added the attribute at Application level as follows.
`<application android:icon="@drawable/icon"
android:label="@string/app_name"
android:theme="@android:style/Theme.Black">`
Then I closed my Activity UI xml file and re-opened it..and the problem was fixed.
I had this problem with a few brand new projects, with no code added yet. Eclipse apparently defaults to using the highest android sdk installed for the layout editor, even if you specify a different version during creation for the minsdk. Project...Clean... rebuilt it and then it was fine.
I had this same problem.. I am using Android 3.0 and developing for the Xoom, and it was already selected. However, changing the version to 2.3.3, and then back to 3.0 also solved the problem.. No rebuilds, re-import of the project, just changed the version, and changed it back again to it's original value. But that may be specific to 3.0. Once solved I didn't go any further into it..
I solved this problem by deleting my custom device configuration.
- Open a layout.xml file.
- Goto "Graphical Layout" view.
- From the leftmost drop down box choose "Custom" to bring up the "Device Configurations" dialogue box.
- Delete your custom configuration.
You may have to close and reopen your layout file.
What if you want to use a custom device configuration? From someone on the android team:
Make sure that if you have custom devices, you edit them and add every available config item into the right listview.
I found copying one of the default configurations and changing values as needed, did the trick.
Android Issue Tracking > Issue 17522: ADT 11 problem "No XML content. Please add a root view or layout to your document." > Comment 10
I'm on WinXP Pro SP3, Eclipse Indigo (3.7.0), building against Android 2.2/Level 8 (Which I installed after encountering the 'missing theme error' when building against Android 2.1-update1). I don't know if changing platforms helped.
Changing the target platform in the "graphical layout" of a layout.xml file from android 2.2 to android 2.1-update1 reintroduced problems from some of my layouts. So maybe you need a complete device configuration and to build against android 2.2 (or, at least, set android 2.2 as the platform for each particular xml file and build the rest of the application against an earlier platform, if need be).
I've had this problem too.
I had a project that was using the Google APIs (Level 7) as the build target. I'm guessing there's something awry in this build that doesnt point nicely to the appropriate theme files. To get around this, I switched my "Project Build Target" to Android 2.1-update1 and it seems to be ok.
To get there.. Within your project open, click Project (from the top menu) -> Properties -> select Android and change the build target.
I may find myself needing the GoogleAPIs at some point, so may need to change back. This may solve the problem, who knows.
Have you added the tag into the manifest? Maybe the designer is looking there for a theme and it is not there.
Hope it helps!
I have solved my problem by changing app theme in manifest file.. like..
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@android:style/Theme.Black.NoTitleBar.Fullscreen" >
Make sure your all other styles.xml present under different values contains your custom theme part.
I had similar problem. In my case I had added a custom theme in values-large folder under res. And it was working at runtime but giving error as yours in eclipse.
So i tried a different solution i.e. adding the custom part(in my case totally there was 3 tags added to styles.xml file) in all other styles.xml file. i.e. styles.xml files under values-normal-hdpi
, values-normal-mdpi
, valuse-v11
and values-v14
...
And BOOM!!! It solved my problem which wasted my whole day.
精彩评论