No grammar constraints (DTD or XML schema) detecte

2019-06-15 07:19发布

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"

8条回答
Rolldiameter
2楼-- · 2019-06-15 07:55

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

查看更多
\"骚年 ilove
3楼-- · 2019-06-15 07:56

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.

查看更多
对你真心纯属浪费
4楼-- · 2019-06-15 07:57

You could also add

<!DOCTYPE androidXML>

below

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

and then just right-click your project and select Validate

查看更多
贼婆χ
5楼-- · 2019-06-15 07:58

In my case I solved this problem by this

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE xml>
查看更多
\"骚年 ilove
6楼-- · 2019-06-15 08:00

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.

查看更多
走好不送
7楼-- · 2019-06-15 08:07

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

查看更多
登录 后发表回答