0

There is this project I am making, and I needed to copy an xml code from another project. After I did so, none of the xml files in my project show up in the Graphical Layout. Instead there is this warning written :

java.lang.NullPointerException
Exception details are logged in Window > Show View > Error Log

When I look it up in Error Log, I get.

Message:

chat_layout.xml: java.lang.NullPointerException

Exception Stack Trace:

java.lang.NullPointerException
    at android.graphics.Bitmap_Delegate.nativeWidth(Bitmap_Delegate.java:291)
    at android.graphics.Bitmap.nativeWidth(Bitmap.java)
    at android.graphics.Bitmap.getWidth(Bitmap.java:909)
    at android.graphics.Bitmap.getScaledWidth(Bitmap.java:957)
    at android.graphics.drawable.BitmapDrawable.computeBitmapSize(BitmapDrawable.java:179)
    at android.graphics.drawable.BitmapDrawable.setBitmap(BitmapDrawable.java:187)
    at android.graphics.drawable.BitmapDrawable.<init>(BitmapDrawable.java:555)
    at android.graphics.drawable.BitmapDrawable.<init>(BitmapDrawable.java:110)
    at com.android.layoutlib.bridge.impl.ResourceHelper.getDrawable(ResourceHelper.java:239)
    at com.android.layoutlib.bridge.bars.CustomBar.loadIcon(CustomBar.java:196)
    at com.android.layoutlib.bridge.bars.CustomBar.loadIconById(CustomBar.java:188)
    at com.android.layoutlib.bridge.bars.CustomBar.loadIconById(CustomBar.java:155)
    at com.android.layoutlib.bridge.bars.FakeActionBar.<init>(FakeActionBar.java:38)
    at com.android.layoutlib.bridge.impl.RenderSessionImpl.inflate(RenderSessionImpl.java:333)
    at com.android.layoutlib.bridge.Bridge.createSession(Bridge.java:332)
    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:440)
    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:683)
    at com.android.ide.eclipse.adt.internal.editors.common.CommonXmlEditor.pageChange(CommonXmlEditor.java:360)
    at org.eclipse.ui.part.MultiPageEditorPart$2.widgetSelected(MultiPageEditorPart.java:290)
    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:2746)
    at org.eclipse.swt.custom.CTabFolder.onMouse(CTabFolder.java:1433)
    at org.eclipse.swt.custom.CTabFolder$1.handleEvent(CTabFolder.java:257)
    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.ui.internal.Workbench.runEventLoop(Workbench.java:2701)
    at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:2665)
    at org.eclipse.ui.internal.Workbench.access$4(Workbench.java:2499)
    at org.eclipse.ui.internal.Workbench$7.run(Workbench.java:679)
    at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332)
    at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:668)
    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(NativeMethodAccessorImpl.java:57)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:601)
    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)

The Graphical Layout works fine for all other xml files for all of my projects in Eclipse, except this one. Everything worked fine before the the copy. What to do ??

The xml file is as follows.

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:background="@android:color/background_dark"
    android:orientation="vertical" >

    <LinearLayout
        android:id="@+id/bottom_write_bar"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true" >

        <EditText
            android:id="@+id/textbox"
            android:layout_width="0dip"
            android:layout_height="fill_parent"
            android:layout_margin="5sp"
            android:layout_weight="1"
            android:hint="Write here"
            android:padding="5sp"
            tools:ignore="HardcodedText" />

        <Button
            android:layout_width="wrap_content"
            android:layout_height="fill_parent"
            android:layout_margin="5sp"
            android:onClick="sendMessage"
            android:paddingBottom="5sp"
            android:paddingLeft="15sp"
            android:paddingRight="15sp"
            android:paddingTop="5sp"
            android:text="Send"
            android:textColor="#FFF"
            tools:ignore="HardcodedText" />

    </LinearLayout>

    <ListView
        android:id="@android:id/list"
        android:layout_width="fill_parent"
        android:layout_height="0dip"
        android:layout_above="@id/bottom_write_bar"
        android:layout_alignParentTop="true"
        android:cacheColorHint="#00000000"
        android:divider="#00000000"
        android:listSelector="#00000000" >
    </ListView>

    <TextView
        android:id="@android:id/empty"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:layout_above="@id/bottom_write_bar"
        android:layout_alignParentTop="true"
        android:gravity="center_vertical|center_horizontal" />

</RelativeLayout>
4

4 回答 4

2

似乎我为我的应用程序使用了不兼容的图标类型。当我更改图标类型时,它起作用了。这是一个愚蠢的错误,但它让我很忙:/

于 2013-09-01T06:01:12.080 回答
0

检查所有来源的 res 图像是否都在 bin/res 文件夹中

于 2013-08-29T03:35:18.210 回答
0

您似乎有两个问题中的任何一个。

  1. 您的文件命名不正确,请检查您的问题选项卡
  2. 重新启动你的eclipse,图形视图有时会占用大量内存并搞砸。如果您运行 Juno,请运行更新,最新版本会更稳定一些。
于 2013-08-29T03:37:44.283 回答
0

我昨天也遇到了这个问题,我刚刚解决了。只需尝试安装更低或更高 API 级别的平台 SDK。一开始,我希望我的应用程序可以在旧平台上工作,所以我用旧风格的主题创建了我的程序,但是当我编辑我的 xml 并使用 4.3 SDK 查看它时,我得到了这个错误。

于 2013-11-01T07:03:26.973 回答