Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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"

like image 823
Hoornet Avatar asked Jun 28 '13 09:06

Hoornet


5 Answers

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

like image 73
user3022856 Avatar answered Nov 16 '22 02:11

user3022856


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"...

like image 38
AntoineP Avatar answered Nov 16 '22 02:11

AntoineP


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

like image 21
Amir.F Avatar answered Nov 16 '22 03:11

Amir.F


In my case I solved this problem by this

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE xml>
like image 20
Rahul Soni Avatar answered Nov 16 '22 02:11

Rahul Soni


You could also add

<!DOCTYPE androidXML>

below

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

and then just right-click your project and select Validate

like image 40
xdevs23 Avatar answered Nov 16 '22 03:11

xdevs23