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

给你一囗甜甜゛ 提交于 2019-12-10 12:33:59

问题


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"


回答1:


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




回答2:


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




回答3:


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




回答4:


In my case I solved this problem by this

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE xml>



回答5:


You could also add

<!DOCTYPE androidXML>

below

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

and then just right-click your project and select Validate




回答6:


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>



回答7:


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.




回答8:


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.



来源:https://stackoverflow.com/questions/17361912/no-grammar-constraints-dtd-or-xml-schema-detected-for-the-document-android

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!