Android / Eclipse / Premature end of xml file

Let me start by recognizing that I found a similar question here, but there was only one answer, and this answer is not applicable in my situation, therefore ...

I am just now falling into Android and came across a point. I am using Eclipse and ran into a problem trying to create a list state listing and continue to receive a "premature file termination" error in Eclipse. I have images in my drawable directory. I create a new file, name it date.xml and enter the following:

<?xml version="1.0" encoding="utf-8"?> <selector xmlns:android="http://schemas.android.com/apk/res/android"> <item android:drawable="@drawable/dategrey" android:state_selected="true" /> <item android:drawable="@drawable/datewhite" /> </selector> 

The exact error I get is "Premature end of file. XML parsing error: No elements found." It bothers me because there is an element. What am I missing?

+7
source share
9 answers

And I decided that. Man, what a foolish thing to make me laugh for two days! I cleaned up the project, rebuilt the xml file, and it works great. I have no idea what this thing is, since I never tried to start the project, so there shouldn't have been a problem with out.out, but it worked. Thanks to everyone who offered advice. I really appreciate your time and attention, helping me with this.

+9
source

You can see this answer .

This human problem was that the file was not created as an XML file, from the point of view of Eclipse. Try File> New> Other ... / select XML.

+3
source

Try

 <?xml version="1.0" encoding="utf-8"?> <selector xmlns:android="http://schemas.android.com/apk/res/android"> <item android:state_selected="true" android:drawable="@drawable/dategrey" /> <item android:drawable="@drawable/datewhite" /> </selector> 

First you need to check the status, and then call a specific option.

+1
source

I had the same problem. Confusing, but it was an XML file out causing the problem. The name was similar, so I did not notice that it was a completely different game_layout_out.xml file. Delete the file and you are fine.

0
source

I got the same error using PhoneGap.

New → Project → Android Project from existing code

Then execute the “Next” and “Browse” project and LEAVE BLANK to copy the projects to the workspace and Finish.

There you go!

0
source

You need to save the new xml file in the res / layout folder .... and do ... thanks

0
source

I just deleted this line

 <?xml version="1.0" encoding="utf-8"?> 

Saved, created, then added again, and everything was fine

0
source

This is what I did: I added a new line at the end of the file, saved the XML file, and deleted the recently added line.

This trivial operation solved my problem with the XML file.

0
source

Is http://schemas.android.com/apk/res/android alive?

The XML editor will attempt to load the XML schema to validate the XML. If the site is down or the XML schema is corrupted, this can lead to these errors.

Try downloading the schema and adding it to your "xml directory" (search in Eclipse settings) to avoid this problem.

-one
source

All Articles