Jacob Holm Mortensen
Jacob Holm Mortensen

Reputation: 71

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

I have a problem with this xml file as said in the title. I dont know how to solve the problem as i have already searched a lot and only found answers like use clean or change validation of this type to ignore none of the above worked as i want to clear this problem so that my R will be generet in the gen folder.

Hope someone can see the problem soon as this is my examprojekt im working on and cant get further without solving this error :)

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".Dekrypter" >

    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_centerHorizontal="true"
        android:layout_centerVertical="true"
        android:text="@string/hello_world" />

</RelativeLayout>

Upvotes: 3

Views: 10693

Answers (5)

Saeb Khanzadeh
Saeb Khanzadeh

Reputation: 13

First put this :
<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE xml>
and after that do this structure:
Click Window > Preferences > XML > XML Files > Validation
Change the setting 'validating files'>'No grammar specified' from warning to ignore.
Re-validate your project. No more warnings now.
thank you AntoineP and TecnoHelp83
https://stackoverflow.com/a/19314230/3117196
https://stackoverflow.com/a/22973854/3117196
worked as well

Upvotes: 0

TecnoHelp83
TecnoHelp83

Reputation: 59

The solution is to put on the top of xml this code. It identify the type of the document to encode!

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

Revalidate the project!

CIAO!!!

Upvotes: 2

AntoineP
AntoineP

Reputation: 3073

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.

Upvotes: 2

Italo Borssatto
Italo Borssatto

Reputation: 15689

Start your XML with:

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

Upvotes: 4

Bryan Herbst
Bryan Herbst

Reputation: 67229

Add

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

To the top of your XML file. This tells the parser that your file is indeed an XML, that it should use XML version 1.0, and that you are using utf-8 encoding.

Without it, the parser doesn't know how it should parse your XML.

Upvotes: 0

Related Questions