Android Studio: Error parsing XML & URI is not registered

后端 未结 8 1429
别跟我提以往
别跟我提以往 2020-12-09 02:38

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)<

相关标签:
8条回答
  • 2020-12-09 02:57

    For me this problem was gone when I have made following changes to my project structure on Android Studio. file->project structure ->SDK Location -> enable check mark for "Use embedded JDK (recommended). Hope this will help someone.

    0 讨论(0)
  • 2020-12-09 02:58

    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.

    0 讨论(0)
  • 2020-12-09 03:04

    Some special characters not allowed here. Directly to assign text then with warning

    android:text="value"
    

    @string file from get then avoid warning

    android:text="@string/hello"
    

    res/values/strings.xml

     <?xml version="1.0" encoding="utf-8"?>
    <resources>
        <string name="hello">Hello!</string>
    </resources>
    
    0 讨论(0)
  • 2020-12-09 03:05

    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!

    0 讨论(0)
  • 2020-12-09 03:08

    My issue was creating new resource directory for some animation work. The files were .xml and I chose file type as "xml". I got this problem. Changing the file type to "values" and the problem went away. No idea why, could someone explain this to me? I'm using Android Studio on an iMac.

    0 讨论(0)
  • 2020-12-09 03:15

    GO to settings >Language&Framework >Schemas&DTD here add Uri used in your code.

    0 讨论(0)
提交回复
热议问题