Search code examples
androidxmlxml-parsingselectoradt

Valid XML file gives "failed to parse" error in Android ADT


I have made a XML file:

<?xml version="1.0" encoding="utf-8"?>
<selector
    xmlns:android="http://schemas.android.com/apk/res/android">
  <item
    android:state_pressed="true"
   android:drawable="@drawable/calender_h" />
  <item
   android:state_pressed="false"
  android:drawable="@drawable/calender_n" />  
</selector>

but it is giving me the following error:

Failed to parse file G:\eclipseHeliosWorkspace\WineCountry\res\drawable\calendar_selector.xml

What could be the problem?


Solution

  • I'm not sure it's the same, but Similar issue happened to me when updating to ADT 15, in a library project. this is the google issue that currently still opened: 21046.

    That's what worked for me:

    1. Remove the library declaration of the project.
    2. Open the layout causing the error (the one which using the selector) in graphical layout.
    3. Clean the project (Project -> Clean)
    4. Close and reopen eclipse. (the layout should be ok now)
    5. You can set the project as library again.

    Hope this helps! (if it's still relevant...)