2014-03-02 35 views
1

我剛開始學習如何在Eclipse中爲Android開發。我正在瀏覽一些關於開發UI的教程,並且我注意到Eclipse中的錯誤日誌會記錄NullPointerExceptions。在Eclipse中編輯Android佈局時的NullPointerException

目前我有一個標籤,按鈕和文本框的佈局。每當我與WYSIWYG UI編輯器進行交互時(例如選擇按鈕),錯誤日誌就會填滿一大堆這些異常。以下是其中一個例外的詳細信息。

eclipse.buildId=v22.3.0-887826 
java.version=1.7.0_51 
java.vendor=Oracle Corporation 
BootLoader constants: OS=win32, ARCH=x86, WS=win32, NL=en_US 
Framework arguments: -product com.android.ide.eclipse.adt.package.product 
Command-line arguments: -os win32 -ws win32 -arch x86 -product com.android.ide.eclipse.adt.package.product 

Error 
Sat Mar 01 19:32:57 PST 2014 


java.lang.NullPointerException 
    at com.android.layoutlib.bridge.impl.RenderSessionImpl.getDefaultProperties(RenderSessionImpl.java:1476) 
    at com.android.layoutlib.bridge.BridgeRenderSession.getDefaultProperties(BridgeRenderSession.java:68) 
    at com.android.ide.eclipse.adt.internal.editors.layout.gle2.ViewHierarchy.getDefaultProperties(ViewHierarchy.java:710) 
    at com.android.ide.eclipse.adt.internal.editors.layout.properties.XmlProperty.getStringValue(XmlProperty.java:209) 
    at com.android.ide.eclipse.adt.internal.editors.layout.properties.XmlProperty.getValue(XmlProperty.java:221) 
    at com.android.ide.eclipse.adt.internal.editors.layout.properties.XmlPropertyEditor.getText(XmlPropertyEditor.java:116) 
    at com.android.ide.eclipse.adt.internal.editors.layout.properties.XmlPropertyEditor.paint(XmlPropertyEditor.java:131) 
    at org.eclipse.wb.internal.core.model.property.table.PropertyTable.drawProperty(PropertyTable.java:1309) 
    at org.eclipse.wb.internal.core.model.property.table.PropertyTable.drawContent(PropertyTable.java:1151) 
    at org.eclipse.wb.internal.core.model.property.table.PropertyTable.handlePaint(PropertyTable.java:1094) 
    at org.eclipse.wb.internal.core.model.property.table.PropertyTable.access$200(PropertyTable.java:64) 
    at org.eclipse.wb.internal.core.model.property.table.PropertyTable$3.handleEvent(PropertyTable.java:187) 
    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.Widget.sendEvent(Widget.java:1077) 
    at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1062) 
    at org.eclipse.swt.widgets.Composite.WM_PRINTCLIENT(Composite.java:1639) 
    at org.eclipse.swt.widgets.Control.windowProc(Control.java:4590) 
    at org.eclipse.swt.widgets.Canvas.windowProc(Canvas.java:341) 
    at org.eclipse.swt.widgets.Display.windowProc(Display.java:4976) 
    at org.eclipse.swt.internal.win32.OS.CallWindowProcW(Native Method) 
    at org.eclipse.swt.internal.win32.OS.CallWindowProc(OS.java:2440) 
    at org.eclipse.swt.widgets.Button.callWindowProc(Button.java:343) 
    at org.eclipse.swt.widgets.Control.windowProc(Control.java:4623) 
    at org.eclipse.swt.widgets.Display.windowProc(Display.java:4989) 
    at org.eclipse.swt.internal.win32.OS.DispatchMessageW(Native Method) 
    at org.eclipse.swt.internal.win32.OS.DispatchMessage(OS.java:2546) 
    at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3756) 
    at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine$9.run(PartRenderingEngine.java:1053) 
    at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332) 
    at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.run(PartRenderingEngine.java:942) 
    at org.eclipse.e4.ui.internal.workbench.E4Workbench.createAndRunUI(E4Workbench.java:86) 
    at org.eclipse.ui.internal.Workbench$5.run(Workbench.java:588) 
    at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332) 
    at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:543) 
    at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:149) 
    at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:124) 
    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:353) 
    at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:180) 
    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:629) 
    at org.eclipse.equinox.launcher.Main.basicRun(Main.java:584) 
    at org.eclipse.equinox.launcher.Main.run(Main.java:1438) 

下面是我的佈局

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:tools="http://schemas.android.com/tools" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:orientation="vertical" 
    android:paddingBottom="@dimen/activity_vertical_margin" 
    android:paddingLeft="@dimen/activity_horizontal_margin" 
    android:paddingRight="@dimen/activity_horizontal_margin" 
    android:paddingTop="@dimen/activity_vertical_margin" 
    tools:context=".StatusActivity" > 

    <TextView 
     android:id="@+id/textView1" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:text="Large Text" 
     android:textAppearance="?android:attr/textAppearanceLarge" /> 

    <Button 
     android:id="@+id/button1" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:layout_marginTop="25dp" 
     android:layout_weight="0.7" 
     android:text="Button" /> 

    <EditText 
     android:id="@+id/editText1" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:layout_marginTop="19dp" 
     android:layout_weight="0.5" 
     android:ems="10" 
     android:inputType="textMultiLine" /> 
</LinearLayout> 
+1

發佈一些java代碼,因爲我沒有看到你的xml代碼有什麼問題。 – Ogen

+0

現在確實沒有任何Java。這是一個新項目,其中一個活動使用在onCreate()和onCreateOptionsMenu()中設置佈局的項目創建() –

+0

其實,我試圖在同一時間學習Git,所以我一直在推動我的工作Github存儲庫。這裏是:https://github.com/aireq/android-bootcamp/tree/master/Yamba –

回答

0

的代碼也許問題是 「ADT包」 內。 你可以嘗試使用其他adt導入該項目嗎? sry,英語不是我的主要語言= /。

相關問題