Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android Studio: Error parsing XML & URI is not registered

After adding a new Activity to my project I get following error while compiling the layout

Gradle: Error parsing XML: not well-formed (invalid token)

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
          android:layout_width="fill_parent"
          android:layout_height="fill_parent"
          android:orientation="vertical" >

<TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:id="@+id/tv_password"
        android:text="<password>"/>
</LinearLayout>

"http://schemas.android.com/apk/res/android" is marked red and hovering pops following message up

URI is not registered ( Setting | Project Settings | Schemas and DTDs )

My Settings>Project Settings>Schemas and DTDs look like that: Settings>Project Settings>Schemas and DTDs

I already found some similar questions around here but nothing helped me to solve this issue. I hope someone has an idea... :)

like image 951
Jonas Avatar asked Jul 07 '13 10:07

Jonas


3 Answers

I was having a similar issue. However, the comments did not assist me in the solution to this issue. This answer from this question actually solved my problem.

Summary:

Go to "File > Project Structure > Modules", click "add" and then click "android" and "apply/ok". That should solve anyone having a similar problem but the comments for this question are not helping you.

like image 106
prolink007 Avatar answered Nov 15 '22 20:11

prolink007


For me, the problem occured when I created my own subfolder for old code.

Specifically, Android Studio threw an error for all layout files that weren't in the default folder ../res/drawable/, but instead placed in my own subfolder ../res/drawable/backup.

like image 7
Antimonit Avatar answered Nov 15 '22 19:11

Antimonit


I got the same error for a long time and none of the answers I found online really helped me, or probably I wasn't looking the right way. At the end what I found out was the way I named the directory. So, I was trying to make the landscape layout for my app and named it layout_land. That kept showing me the URI is not registered error. I just had to change the directory name to layout-land.

Summary: No underscores in directory names!

like image 3
moonyWolf Avatar answered Nov 15 '22 21:11

moonyWolf