2011-10-20 106 views
2

所以我剛剛安裝了Android SDK和用於eclipse的ADT插件並遇到了問題。main.xml:java.lang.NullPointerException Android Eclipse錯誤

當我轉到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。

任何人有任何建議

+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是錯誤的。

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

+0

沒有運氣,無論我在右上角選擇什麼設備,在嘗試查看圖形佈局時,仍然會得到java.lang.NullPointerException,就像它缺少這一切一樣。就像我試圖在SDK和ADT上重新安裝它一樣,發生同樣的事情。 – Puresilence