当我尝试在 ADT 的图形布局中查看我的布局时出现此错误。该项目运行良好,一开始没有任何问题。此外,如果我开始一个新项目并在图形布局中打开一个布局 xml 文件,它会很好地加载它。这些是 xml 文件代码:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<TextView
android:id="@+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
android:text="@string/tot"
android:textSize="40sp" />
<Button
android:id="@+id/btn_Add"
android:layout_width="450sp"
android:layout_height="wrap_content"
android:gravity="center"
android:text="@string/add" />
<Button
android:id="@+id/btn_Sub"
android:layout_width="450sp"
android:layout_height="wrap_content"
android:layout_marginTop="14dp"
android:gravity="center"
android:text="@string/sub" />
</LinearLayout>
日志猫:
java.lang.NullPointerException
at android.graphics.Bitmap_Delegate.nativeWidth(Bitmap_Delegate.java:296)
at android.graphics.Bitmap.nativeWidth(Bitmap.java)
at android.graphics.Bitmap.getWidth(Bitmap.java:917)
at android.graphics.Bitmap.getScaledWidth(Bitmap.java:965)
at android.graphics.drawable.BitmapDrawable.computeBitmapSize(BitmapDrawable.java:183)
at android.graphics.drawable.BitmapDrawable.setBitmap(BitmapDrawable.java:191)
at android.graphics.drawable.BitmapDrawable.<init>(BitmapDrawable.java:604)
at android.graphics.drawable.BitmapDrawable.<init>(BitmapDrawable.java:114)
at com.android.layoutlib.bridge.impl.ResourceHelper.getDrawable(ResourceHelper.java:239)
at com.android.layoutlib.bridge.bars.CustomBar.loadIcon(CustomBar.java:212)
at com.android.layoutlib.bridge.bars.CustomBar.loadIconById(CustomBar.java:204)
at com.android.layoutlib.bridge.bars.CustomBar.loadIconById(CustomBar.java:171)
at com.android.layoutlib.bridge.bars.FakeActionBar.<init>(FakeActionBar.java:38)
at com.android.layoutlib.bridge.impl.RenderSessionImpl.inflate(RenderSessionImpl.java:347)
at com.android.layoutlib.bridge.Bridge.createSession(Bridge.java:336)
at com.android.ide.common.rendering.LayoutLibrary.createSession(LayoutLibrary.java:333)
at com.android.ide.eclipse.adt.internal.editors.layout.gle2.RenderService.createRenderSession(RenderService.java:451)
at com.android.ide.eclipse.adt.internal.editors.layout.gle2.GraphicalEditorPart.renderWithBridge(GraphicalEditorPart.java:1545)
at com.android.ide.eclipse.adt.internal.editors.layout.gle2.GraphicalEditorPart.recomputeLayout(GraphicalEditorPart.java:1302)
at com.android.ide.eclipse.adt.internal.editors.layout.gle2.GraphicalEditorPart.activated(GraphicalEditorPart.java:1059)
at com.android.ide.eclipse.adt.internal.editors.layout.LayoutEditorDelegate.delegatePageChange(LayoutEditorDelegate.java:686)
at com.android.ide.eclipse.adt.internal.editors.common.CommonXmlEditor.pageChange(CommonXmlEditor.java:360)
at org.eclipse.ui.part.MultiPageEditorPart$2.widgetSelected(MultiPageEditorPart.java:292)
at org.eclipse.swt.widgets.TypedListener.handleEvent(TypedListener.java:248)
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.Widget.notifyListeners(Widget.java:774)
at org.eclipse.swt.custom.CTabFolder.setSelection(CTabFolder.java:3028)
at org.eclipse.swt.custom.CTabFolder.onMouse(CTabFolder.java:1749)
at org.eclipse.swt.custom.CTabFolder$1.handleEvent(CTabFolder.java:278)
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:4169)
at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3758)
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)