No grammar constraints (DTD or XML schema) detected for the document (Android)
Asked Answered
L

7

13

I have the same problem as many here, but i DO HAVE xmlns:android and the xml=... tags. Still I have the same error. I don't wan't just click the ignore instead of warning in the settings so hence the question here posted.

The source is:

<?xml version="1.0" encoding="utf-8"?>
<GridLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent" >


</GridLayout>

The error:

"No grammar constraints (DTD or XML schema) detected for the document. grid_layout_test2.xml /SomeProject/res/layout line 1 XML Problem"

Lemmuela answered 28/6, 2013 at 9:52 Comment(0)
P
20

For me it was a Problem with character encoding and unix filemode running eclipse on Windows:

Just marked the complete code, cutted and pasted it back (in short: CtrlA-CtrlX-CtrlV) and everything was fine - no more "No grammar constraints..." warnings

Pickaback answered 22/11, 2013 at 18:28 Comment(2)
worked for me. add to copy from eclipse (control c), pasted in Notepad (control v), then selected it all in notepad (control a), copied it (control c) and finally pasted it back into eclipse. Pasting and copying from notepad removes all text formatting since notepad only supports plain text.Concepcionconcept
Worked pretty well, thank you. Although on some occasions I had to cut\paste\save\cut\paste to make it work. After the first paste Eclipse moved the warning marker to the end of the file, clearly some encoding or bad char issue.Vetter
D
13

I retrieve a solution from a bug issue :

  1. Click Window > Preferences > XML > XML Files > Validation
  2. Change the setting 'validating files'>'No grammar specified' from warning to ignore.
  3. Re-validate your project. No more warnings now.

It works for me.

Be careful, my solution is a kind of "I do not understand so that I prefer to deactivate"...

Damages answered 11/10, 2013 at 9:5 Comment(2)
Thank you, but this is exactly what i didn't want. If you take a look at my question once again you will see that: " I don't wan't just click the ignore instead of warning in the settings so hence the question here posted." :)Lemmuela
@Lemmuela it seems to be a bug in Eclipse, since even after deleting all the content from one of the files and saving it, the warning still remained. With some files I managed to get the warning off by doing the CtrlA-CtrlX-CtrlV, but once I ignored all warnings as this answer explains and placed the no grammar back on to warning status, those same files had the same warning again... The <!DOCTYPE ...> solution didn't work for me. So I'd not spend more time in trying to figure this out.Introspect
M
4

Solution For Eclipse:

add <!DOCTYPE something> to the begining of each problematic XML,

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

you can write anything for doctype, but basically it's supposed to be manifest, activity, etc. from what I understand

Minify answered 10/10, 2013 at 12:49 Comment(1)
DOCTYPE Descriptions (DTDs) are very well explained here: xmlwriter.net/xml_guide/doctype_declaration.shtml Basically, it should be '<!DOCTYPE root_element>' or in your case: '<!DOCTYPE GridLayout>'Jetsam
O
4

In my case I solved this problem by this

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE xml>
Oosphere answered 11/2, 2016 at 7:10 Comment(0)
B
0

try the below

<?xml version="1.0" encoding="utf-8"?>
<GridLayout xmlns:android="http://schemas.android.com/apk/res/android"
      xmlns:tools="http://schemas.android.com/tools"
      android:layout_width="match_parent"
      android:id="@+id/grid"
      android:layout_height="match_parent" >

</GridLayout>
Bilinear answered 28/6, 2013 at 10:1 Comment(3)
do you have "xmlns:android="schemas.android.com/apk/res/android" in the dtd settings? I don'tLemmuela
try this #4552283Bilinear
that link isn't current. For example, the answer says that yone should select: As key type: Namespace name But this option doesn't exist any more...Lemmuela
G
0

Move marked files outside project folder.( or Move the folder containint marked files.) Reflesh the project.(Select the project in Project explorer, ->) Move back files. Reflesh the project.

Grot answered 1/11, 2014 at 6:16 Comment(0)
S
0

simple way is first select all(ctrl+a) cut it (ctrl+x) than past, same error comes on most bottom do same process again and save it, angain do the above process, than your xml file is free from this type of error.

Strachan answered 5/2, 2015 at 6:57 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.