android studio中xml文件报错: URI is not registered的解决办法

问题一:URI is not registered (Settings | Languages & Frameworks | Schemas and DTDs)

假如是下面框框内是报红色字体并且提示此错。

 

android studio中xml文件报错: URI is not registered的解决办法

 

解决方案:
进入 File->Settings->Languages&Frameworks->Schemas and DTDs目录下:

android studio中xml文件报错: URI is not registered的解决办法

点击绿色的加号,将报错的命名空间一一复制进去,点击Applay->OK

 

问题二:Attribute android:layout_width is not allowed here

属性值报红并且提示此错误,原因是因为SDK的版本和andriod的版本不一致。

解决二:

android studio中xml文件报错: URI is not registered的解决办法

android studio中xml文件报错: URI is not registered的解决办法

 

最后进行:File → Sync Project with Gradle Files  ( 将项目与渐变文件同步)

 

文章参考于:

https://www.jianshu.com/p/ce02feaeaf23

https://blog.csdn.net/zahngjialiang/article/details/60133357