如何修复 Eclipse/Android 安装?图形 XML 编辑器中的 PNG 加载问题
很长一段时间以来,我的带有 Android 插件的 Eclipse 环境都运行顺利。在软件更新过程中应用的更新的某个地方,它崩溃了。开始发生的第一个问题是在运行布局文件的 Android 插件图形编辑器时丢失“按钮”Form Widget 图形。我在错误日志中收到以下相关错误:
!MESSAGE voice_recog.xml: android.webkit.WebView
!MESSAGE main_new.xml: Failed lot load /Developer/android-sdk-mac_x86-1.5_r3/platforms/android-11/data/res/drawable-hdpi/btn_default_normal.9.png
!STACK 0
javax.imageio.IIOException: Error reading PNG metadata
我在硬盘上找到了 png 文件并从 Finder 启动了图像查看器。它显示没有错误。我不知道为什么 IDE 无法将其加载到图形编辑器中。如果您查看文章末尾的详细错误日志转储,您将看到发生的异常是 java.io.EOFException (“由:java.io.EOFException”引起)。
我注意到其中一个更新在我的硬盘上安装了 Android-12,并且 IDE 正在 Android-11 目录中查找 PNG。然而,正如我之前所说,该文件确实存在于错误消息中显示的 Android-11 路径中。我只是指出这一点,以防它可能表明我的设置中存在其他问题。
注意:我尝试将图形布局编辑器从“3.7 英寸 WVGA”切换到其他设备,但我遇到了比以前更多的 PNG 文件加载错误(更多)以及 ClassCast 异常。我还尝试将 Android 平台从 3.0 切换到我的目标 1.6,但这也没有帮助。就好像 PNG 文件加载代码现在出了问题。我希望不要完全重新安装 Eclipse 和 ADT,特别是因为我最终可能会回到同样的麻烦点,所以如果有人遇到过这些问题并解决了它们,请回复。
以下是 PNG 文件原始加载失败的完整错误日志跟踪:
!ENTRY com.android.ide.eclipse.adt 4 0 2011-06-23 04:07:39.972
!MESSAGE web2voice_main_new.xml: Failed lot load /Developer/android-sdk-mac_x86-1.5_r3/platforms/android-11/data/res/drawable-hdpi/btn_default_normal.9.png
!STACK 0
javax.imageio.IIOException: Error reading PNG metadata
at com.sun.imageio.plugins.png.PNGImageReader.readMetadata(PNGImageReader.java:695)
at com.sun.imageio.plugins.png.PNGImageReader.readImage(PNGImageReader.java:1314)
at com.sun.imageio.plugins.png.PNGImageReader.read(PNGImageReader.java:1601)
at javax.imageio.ImageIO.read(ImageIO.java:1400)
at javax.imageio.ImageIO.read(ImageIO.java:1322)
at com.android.ninepatch.GraphicsUtilities.loadCompatibleImage(GraphicsUtilities.java:37)
at com.android.ninepatch.NinePatch.load(NinePatch.java:96)
at com.android.layoutlib.bridge.impl.ResourceHelper.getNinePatchDrawable(ResourceHelper.java:279)
at com.android.layoutlib.bridge.impl.ResourceHelper.getDrawable(ResourceHelper.java:190)
at com.android.layoutlib.bridge.android.BridgeResources.getDrawable(BridgeResources.java:162)
at android.graphics.drawable.StateListDrawable.inflate(StateListDrawable.java:173)
at android.graphics.drawable.Drawable.createFromXmlInner(Drawable.java:832)
at android.graphics.drawable.Drawable.createFromXml(Drawable.java:769)
at com.android.layoutlib.bridge.impl.ResourceHelper.getDrawable(ResourceHelper.java:214)
at com.android.layoutlib.bridge.android.BridgeTypedArray.getDrawable(BridgeTypedArray.java:693)
at android.view.View.<init>(View.java:2471)
at android.widget.TextView.<init>(TextView.java:368)
at android.widget.Button.<init>(Button.java:108)
at android.widget.Button.<init>(Button.java:104)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
at java.lang.reflect.Constructor.newInstance(Constructor.java:501)
at android.view.LayoutInflater.createView(LayoutInflater.java:576)
at com.android.layoutlib.bridge.android.BridgeInflater.onCreateView(BridgeInflater.java:83)
at android.view.LayoutInflater.onCreateView(LayoutInflater.java:644)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:669)
at com.android.layoutlib.bridge.android.BridgeInflater.createViewFromTag(BridgeInflater.java:128)
at android.view.LayoutInflater_Delegate.rInflate(LayoutInflater_Delegate.java:76)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:702)
at android.view.LayoutInflater_Delegate.rInflate(LayoutInflater_Delegate.java:79)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:702)
at android.view.LayoutInflater.inflate(LayoutInflater.java:479)
at android.view.LayoutInflater.inflate(LayoutInflater.java:367)
at com.android.layoutlib.bridge.impl.RenderSessionImpl.inflate(RenderSessionImpl.java:315)
at com.android.layoutlib.bridge.Bridge.createSession(Bridge.java:314)
at com.android.ide.common.rendering.LayoutLibrary.createSession(LayoutLibrary.java:324)
at com.android.ide.eclipse.adt.internal.editors.layout.gle2.GraphicalEditorPart.renderWithBridge(GraphicalEditorPart.java:1510)
at com.android.ide.eclipse.adt.internal.editors.layout.gle2.GraphicalEditorPart.renderWithBridge(GraphicalEditorPart.java:1347)
at com.android.ide.eclipse.adt.internal.editors.layout.gle2.GraphicalEditorPart.recomputeLayout(GraphicalEditorPart.java:1078)
at com.android.ide.eclipse.adt.internal.editors.layout.gle2.GraphicalEditorPart.activated(GraphicalEditorPart.java:904)
at com.android.ide.eclipse.adt.internal.editors.layout.LayoutEditor.pageChange(LayoutEditor.java:403)
at org.eclipse.ui.part.MultiPageEditorPart$2.widgetSelected(MultiPageEditorPart.java:290)
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.Display.sendEvent(Display.java:3783)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1375)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1398)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1383)
at org.eclipse.swt.widgets.Widget.notifyListeners(Widget.java:1195)
at org.eclipse.swt.custom.CTabFolder.setSelection(CTabFolder.java:2743)
at org.eclipse.swt.custom.CTabFolder.onMouse(CTabFolder.java:1429)
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.Display.sendEvent(Display.java:3783)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1375)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1398)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1383)
at org.eclipse.swt.widgets.Widget.notifyListeners(Widget.java:1195)
at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:3629)
at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3284)
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(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:592)
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)
Caused by: java.io.EOFException
at javax.imageio.stream.ImageInputStreamImpl.readFully(ImageInputStreamImpl.java:330)
at java.io.DataInputStream.readUTF(DataInputStream.java:565)
at javax.imageio.stream.ImageInputStreamImpl.readUTF(ImageInputStreamImpl.java:309)
at com.sun.imageio.plugins.png.PNGImageReader.parse_iTXt_chunk(PNGImageReader.java:443)
at com.sun.imageio.plugins.png.PNGImageReader.readMetadata(PNGImageReader.java:652)
... 80 more
-- roschler
For quite a while my Eclipse environment with the Android plug-in was running smoothly. Somewhere along the line of updates applied during the Software updates process it broke. The first problem that started happening was the loss of the "button" Form Widget graphics when running the Android plug-in Graphical Editor for layout files. I get the following related errors in the Error log:
!MESSAGE voice_recog.xml: android.webkit.WebView
!MESSAGE main_new.xml: Failed lot load /Developer/android-sdk-mac_x86-1.5_r3/platforms/android-11/data/res/drawable-hdpi/btn_default_normal.9.png
!STACK 0
javax.imageio.IIOException: Error reading PNG metadata
I located the png file on my hard disk and launched the image viewer from Finder. It displayed without error. I don't know why the IDE is having trouble loading it into the Graphical Editor. If you look at the detailed Error Log dump at the end of the post you will see that the Exception occurring is a java.io.EOFException ("Caused by: java.io.EOFException").
I noticed that one of the updates installed Android-12 on my hard disk and that the IDE is looking for PNG's in the Android-11 directory. However as I stated before, the file does exist in the Android-11 path shown in the error messages. I'm just pointing this out in case it may indicate some other problem in my setup.
NOTE: I tried switching the Graphical Layout editor to a different device from "3.7 inch WVGA" to several of the others and I got even more PNG file load errors than before (a lot more) and also a ClassCast Exception. I also tried switching the Android Platform from 3.0 to my target 1.6 and that did not help either. It's as if there is something just broken with the PNG file loading code now. I'm hoping not to do a full re-install of Eclipse and the ADT, especially since I could end up right back in the same trouble spot, so if anyone has experienced these problems and solved them, please respond.
Here is the full Error Log trace for the original failed load of the PNG file:
!ENTRY com.android.ide.eclipse.adt 4 0 2011-06-23 04:07:39.972
!MESSAGE web2voice_main_new.xml: Failed lot load /Developer/android-sdk-mac_x86-1.5_r3/platforms/android-11/data/res/drawable-hdpi/btn_default_normal.9.png
!STACK 0
javax.imageio.IIOException: Error reading PNG metadata
at com.sun.imageio.plugins.png.PNGImageReader.readMetadata(PNGImageReader.java:695)
at com.sun.imageio.plugins.png.PNGImageReader.readImage(PNGImageReader.java:1314)
at com.sun.imageio.plugins.png.PNGImageReader.read(PNGImageReader.java:1601)
at javax.imageio.ImageIO.read(ImageIO.java:1400)
at javax.imageio.ImageIO.read(ImageIO.java:1322)
at com.android.ninepatch.GraphicsUtilities.loadCompatibleImage(GraphicsUtilities.java:37)
at com.android.ninepatch.NinePatch.load(NinePatch.java:96)
at com.android.layoutlib.bridge.impl.ResourceHelper.getNinePatchDrawable(ResourceHelper.java:279)
at com.android.layoutlib.bridge.impl.ResourceHelper.getDrawable(ResourceHelper.java:190)
at com.android.layoutlib.bridge.android.BridgeResources.getDrawable(BridgeResources.java:162)
at android.graphics.drawable.StateListDrawable.inflate(StateListDrawable.java:173)
at android.graphics.drawable.Drawable.createFromXmlInner(Drawable.java:832)
at android.graphics.drawable.Drawable.createFromXml(Drawable.java:769)
at com.android.layoutlib.bridge.impl.ResourceHelper.getDrawable(ResourceHelper.java:214)
at com.android.layoutlib.bridge.android.BridgeTypedArray.getDrawable(BridgeTypedArray.java:693)
at android.view.View.<init>(View.java:2471)
at android.widget.TextView.<init>(TextView.java:368)
at android.widget.Button.<init>(Button.java:108)
at android.widget.Button.<init>(Button.java:104)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
at java.lang.reflect.Constructor.newInstance(Constructor.java:501)
at android.view.LayoutInflater.createView(LayoutInflater.java:576)
at com.android.layoutlib.bridge.android.BridgeInflater.onCreateView(BridgeInflater.java:83)
at android.view.LayoutInflater.onCreateView(LayoutInflater.java:644)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:669)
at com.android.layoutlib.bridge.android.BridgeInflater.createViewFromTag(BridgeInflater.java:128)
at android.view.LayoutInflater_Delegate.rInflate(LayoutInflater_Delegate.java:76)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:702)
at android.view.LayoutInflater_Delegate.rInflate(LayoutInflater_Delegate.java:79)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:702)
at android.view.LayoutInflater.inflate(LayoutInflater.java:479)
at android.view.LayoutInflater.inflate(LayoutInflater.java:367)
at com.android.layoutlib.bridge.impl.RenderSessionImpl.inflate(RenderSessionImpl.java:315)
at com.android.layoutlib.bridge.Bridge.createSession(Bridge.java:314)
at com.android.ide.common.rendering.LayoutLibrary.createSession(LayoutLibrary.java:324)
at com.android.ide.eclipse.adt.internal.editors.layout.gle2.GraphicalEditorPart.renderWithBridge(GraphicalEditorPart.java:1510)
at com.android.ide.eclipse.adt.internal.editors.layout.gle2.GraphicalEditorPart.renderWithBridge(GraphicalEditorPart.java:1347)
at com.android.ide.eclipse.adt.internal.editors.layout.gle2.GraphicalEditorPart.recomputeLayout(GraphicalEditorPart.java:1078)
at com.android.ide.eclipse.adt.internal.editors.layout.gle2.GraphicalEditorPart.activated(GraphicalEditorPart.java:904)
at com.android.ide.eclipse.adt.internal.editors.layout.LayoutEditor.pageChange(LayoutEditor.java:403)
at org.eclipse.ui.part.MultiPageEditorPart$2.widgetSelected(MultiPageEditorPart.java:290)
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.Display.sendEvent(Display.java:3783)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1375)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1398)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1383)
at org.eclipse.swt.widgets.Widget.notifyListeners(Widget.java:1195)
at org.eclipse.swt.custom.CTabFolder.setSelection(CTabFolder.java:2743)
at org.eclipse.swt.custom.CTabFolder.onMouse(CTabFolder.java:1429)
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.Display.sendEvent(Display.java:3783)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1375)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1398)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1383)
at org.eclipse.swt.widgets.Widget.notifyListeners(Widget.java:1195)
at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:3629)
at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3284)
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(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:592)
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)
Caused by: java.io.EOFException
at javax.imageio.stream.ImageInputStreamImpl.readFully(ImageInputStreamImpl.java:330)
at java.io.DataInputStream.readUTF(DataInputStream.java:565)
at javax.imageio.stream.ImageInputStreamImpl.readUTF(ImageInputStreamImpl.java:309)
at com.sun.imageio.plugins.png.PNGImageReader.parse_iTXt_chunk(PNGImageReader.java:443)
at com.sun.imageio.plugins.png.PNGImageReader.readMetadata(PNGImageReader.java:652)
... 80 more
-- roschler
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我通过将图形布局框右上角的 Eclipse 从 Android 3.0 中取出来解决了这个问题。我把版本降到了 Android 2.3.3,一旦它完成加载这个版本,我就安全了。 “按钮”png 加载得很好。
I got around this problem by taking Eclipse out of Android 3.0 in the top right corner of the Graphical Layout box. I dropped the version down to Android 2.3.3 and once it finished loading this version I was in the clear. The 'button' png loaded just fine.