Android XML Viewer failing
I've been having this problem for a while:
Here is my header.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_height="wrap_content"
android:layou开发者_开发问答t_width="fill_parent"
android:orientation="vertical">
<ImageView android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:src="@drawable/logo_text"/>
</LinearLayout>
And this what the Eclipse/Android XML viewer is giving me:
Unable to resolve drawable "C:\Users\Me\MyApp\res\drawable-hdpi\logo_text.png" in attribute "src"
This happens in other projects as well for seemingly random images. Project->Clean doesn't help either. I know this has to be an issue with my machine or eclipse installation because it doesn't happen on my work machine, only my home laptop.
There are no problems when the app is installed, but it would be nice to be able to see layout changes without having to install the app over and over again.
EDIT
I also get these messages anytime I use a custom View in a layout file:
error!
UnsupportedClassVersionError: Bad version number in .class file
Unable to resolve drawable "C:\Users\Me\MyApp\res\drawable-hdpi\logo_text.png" in attribute "src"
Exception details are logged in Window > Show View > Error Log
I sometimes have weird issues like this when importing new images into my project. Do you have any other res-image directories with different versions of this file? You may try removing the png and re-adding to the project.
The error message explicitly mentions the -hdpi version of the drawable directory. Have you got that image in all of the different versions of the drawable directory? Perhaps it is in res/drawable-ldpi or res/drawable-mdpi but not res/drawable-hdpi?
If you don't already have one, you could create a plain res/drawable folder and add the image there, then one would expect the system to fall back to that whenever it didn't find a definition-specific version.
Actually try to put an id tag on ImageView : android:id=:"@+id/imageView"
.Tell me if it is working or not.
精彩评论