main.xml:java.lang.NullPointerException Android Eclipse错误

时间:2011-10-20 10:10:42

标签: android eclipse sdk adt

所以我刚刚为eclipse安装了Android SDK和ADT插件,遇到了问题。

当我转到main.xml中的图形布局时,没有显示布局。相反,我只是得到了这个错误

    $java.lang.NullPointerException
at sun.awt.FontConfiguration.getInitELC(Unknown Source)
at sun.awt.FontConfiguration.initFontConfig(Unknown Source)
at sun.awt.FontConfiguration.<init>(Unknown Source)
at sun.awt.windows.WFontConfiguration.<init>(Unknown Source)
at sun.awt.Win32GraphicsEnvironment.createFontConfiguration(Unknown Source)
at sun.java2d.SunGraphicsEnvironment$2.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at sun.java2d.SunGraphicsEnvironment.<init>(Unknown Source)
at sun.awt.Win32GraphicsEnvironment.<init>(Unknown Source)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
at java.lang.reflect.Constructor.newInstance(Unknown Source)
at java.lang.Class.newInstance0(Unknown Source)
at java.lang.Class.newInstance(Unknown Source)
at java.awt.GraphicsEnvironment.getLocalGraphicsEnvironment(Unknown Source)
at sun.font.FontDesignMetrics.getDefaultFrc(Unknown Source)
at sun.font.FontDesignMetrics.getMetrics(Unknown Source)
at sun.awt.SunToolkit.getFontMetrics(Unknown Source)
at sun.awt.windows.WToolkit.getFontMetrics(Unknown Source)
at android.graphics.Paint_Delegate.updateFontObject(Paint_Delegate.java:1062)
at android.graphics.Paint_Delegate.reset(Paint_Delegate.java:1039)
at android.graphics.Paint_Delegate.<init>(Paint_Delegate.java:991)
at android.graphics.Paint_Delegate.native_init(Paint_Delegate.java:614)
at android.graphics.Paint.native_init(Paint.java)
at android.graphics.Paint.<init>(Paint.java:194)
at android.graphics.Paint.<init>(Paint.java:184)
at android.view.ViewGroup.<init>(ViewGroup.java:278)
at android.widget.LinearLayout.<init>(LinearLayout.java:116)
at com.android.layoutlib.bridge.impl.RenderSessionImpl.inflate(RenderSessionImpl.java:227)
at com.android.layoutlib.bridge.Bridge.createSession(Bridge.java:318)
at com.android.ide.common.rendering.LayoutLibrary.createSession(LayoutLibrary.java:325)
at com.android.ide.eclipse.adt.internal.editors.layout.gle2.RenderService.createRenderSession(RenderService.java:372)
at com.android.ide.eclipse.adt.internal.editors.layout.gle2.GraphicalEditorPart.renderWithBridge(GraphicalEditorPart.java:1317)
at com.android.ide.eclipse.adt.internal.editors.layout.gle2.GraphicalEditorPart.recomputeLayout(GraphicalEditorPart.java:1071)
at com.android.ide.eclipse.adt.internal.editors.layout.gle2.GraphicalEditorPart$ConfigListener.onConfigurationChange(GraphicalEditorPart.java:493)
at com.android.ide.eclipse.adt.internal.editors.layout.configuration.ConfigurationComposite.onRenderingTargetChange(ConfigurationComposite.java:2192)
at com.android.ide.eclipse.adt.internal.editors.layout.configuration.ConfigurationComposite.access$4(ConfigurationComposite.java:2157)
at com.android.ide.eclipse.adt.internal.editors.layout.configuration.ConfigurationComposite$2.widgetSelected(ConfigurationComposite.java:441)
at org.eclipse.swt.widgets.TypedListener.handleEvent(TypedListener.java:234)
at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1053)
at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:4066)
at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3657)
at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:2640)
at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:2604)
at org.eclipse.ui.internal.Workbench.access$4(Workbench.java:2438)
at org.eclipse.ui.internal.Workbench$7.run(Workbench.java:671)
at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332)
at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:664)
at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:149)
at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:115)
at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:196)
at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:110)
at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:79)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:369)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.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:620)
at org.eclipse.equinox.launcher.Main.basicRun(Main.java:575)
at org.eclipse.equinox.launcher.Main.run(Main.java:1408)
at org.eclipse.equinox.launcher.Main.main(Main.java:1384)

无论我在哪个Android版本,我仍然会收到此错误。我试过卸载SDK和插件,但无济于事。我正在使用SDK r14工具和ADT 14.0。

任何人都有任何建议

1 个答案:

答案 0 :(得分:6)

打开XML文件后会立即发生吗?

可能值得检查XML文件中的源代码。打开包含文件的目录并进行编辑(在记事本等中),然后粘贴以下内容:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
              android:layout_width="fill_parent" 
              android:layout_height="fill_parent" 
              android:orientation="vertical" >
    <TextView android:id="@+id/text"
              android:layout_width="wrap_content"
              android:layout_height="wrap_content"
              android:text="Hi, did this work?" />
</LinearLayout>

这就像它得到的一样简单。如果可行,您知道当前main.xml中的XML是错误的。

也值得重建/清理您的项目。