[android] Why is Android Studio reporting "URI is not registered"?

So I've given Android Studio a try, because I really like Resharper and noticed that the IDE had some of their functionality built into it. Having now created a default new project, I added a new layout file and wanted to change the existing default 'hello world' example layout, and I got an "URI is not registered" error on the following lines:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"

I've done nothing else to the default generated project yet. I've come across another question that seems to be related (Intellij Android project schema URI not registered?), but just ignoring something feels odd to me. I actually tried it, but that causes RelativeLayout (and probably all other Android related stuff) to be not recognised any more (error message: "Cannot find the declaration of element 'RelativeLayout'").

Any ideas on how to solve this problem?enter image description hereenter image description hereenter image description here

This question is related to android android-studio

The answer is


Its a plugins problems.

  1. Restart Your android studio.
  2. It will show a pop window for enable plugins
  3. click on enable plugins and then click on Okay.

then it will automatic restart your studio and works will fine.

hope it will works.


I had this problem and for me it was due to creating and manipulating resource files outside Android Studio. I followed the instructions on creating new resource files and folders through Android Studio and solved the problem. You need to create a new Resource File Not directory. It will let you specify or create a directory for you if you need it. If you are creating directories for layouts for different versions, enter the info at the top including the name of the resource file you want to copy to the new folder and select Version and enter the Android version. It will create the appropriate directory with a copy of your resource in it.


it turns out I was editing the DEBUG version of the xml, to fix it, simply close the tab that has the error and re-open it


This problem appeared suddenly for me, without any reason. I just closed all the tabs in Android Studio and re-opened the xml file which had problems. Problem solved! :)


For me this was because I was using a debug and release build variant. I added the new folders src/debug/res/layout/some_layout.xml file manually, and it didn't recognize the URI. I switched the build variant to release, and then back to debug. This caused Android Studio to reload something, and the error went away.

EDIT: Also check that you have the correct filename. I had this issue again by adding a debug AndroidManifest.xml, but mistakenly named it AndroidManifest.xml.xml.


Select appropriate flavour in Build Variants.

If you are viewing a particular file under Flavour1, select that flavor in BuildVariants window.

If your IDE is Android Studio (3.2.1 as of this writing), you should find Build Variants window on the lower left, aligned vertically.


The new build system in Android Studio creates a build folder. The code inspection barfs on this folder as well as the gradle folder. These folders should proably be ignored when running code inspection.

I have raised an issue with the Android Studio team at:

https://code.google.com/p/android/issues/detail?id=56415


My problem was that my folders were structured as:

MyProject/ res/ layout/ main.xml layout-land/ main.xml

(My Slayout-land folder was in my layout folder)

I changed the structure to this and it worked for me:

MyProject/ res/ layout/ main.xml layout-land/ main.xml

I hope that this helps!


Don't know the reason behind this error but I found out this somewhere and it solved my problem.

  • Go to "File > Project Structure > Modules"
  • Click "add (+)"
  • Click "android" and "apply" and then "ok"

For me, i clone a project from gitlab, there is table of contents:

TradeClient/TradeClient/app/...

then i encounter this problem, i solve the problem by below method:

  • remove the middle path "TradeClient", as TradeClient/app/...
  • then File -> Invalidate Caches / Restart...

In Android Studio 3.1.2 this error occurs due to Wrong validation of the cache memory.,

Go to Project folder and delete all the contents in .idea folder

This will delete the cache memory and reloading the project will create new cache memory folder and makes it good to go.,


For me, the offending xml files were missing the header line...

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

Adding that fixed it.


Another suggestion, which was the solution for me: I got the error in the line

<resources xmlns:ns1="http://schemas.android.com/tools" xmlns:ns2="urn:oasis:names:tc:xliff:document:1.2">

in the values.xml file that was automatically generated during the build process.

It was solved by adding the android prefix in the styles.xml file.

<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
        <!-- Customize your theme here. -->
        <item name="colorPrimary">@color/colorPrimary</item>
        <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
        <item name="colorAccent">@color/colorAccent</item>
        <item name="textColorPrimary">@color/textColorPrimary</item>
        <item name="colorBackground">@color/colorPrimaryDark</item>
    </style>

had to be changed to

<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
        <!-- Customize your theme here. -->
        <item name="colorPrimary">@color/colorPrimary</item>
        <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
        <item name="colorAccent">@color/colorAccent</item>
        <item name="android:textColorPrimary">@color/textColorPrimary</item>
        <item name="android:colorBackground">@color/colorPrimaryDark</item>
    </style>

i had the same error. I solved it by importing the project again to the android studio.


Try to Install the android tracker plugin. you will find it on the studio.

Restart the studio


Started getting this again, What actually works now is to add some rubbish inside build.gradle. Then try and sync. When it fails remove the rubbish and re-sync. After indexing, it works.


What fixed it for me that I haven't seen mentioned so far - if you have multiple 'flavors', make sure the currently selected 'build variant' matches the flavor for the layout file you're trying to view.


Any solution mentioned here helped me. I'll post my problem just in case is helpful to anyone. In my case the error was happening using data binding. It seems that using data binding xmls intermediates are created. If there is an error trying to open the error will show the intermediate xml with this "URI not registered" instead of opening the right xml with the error.


Anyone getting this error right after project import might be hitting an unsuccessful initial gradle import/sync. Usually it is encountered with serious errors (blinking exclamation mark in the lower right corner). For me this was the very strange cause (project folder was symlinked): https://stackoverflow.com/a/52952148/44166


Sometimes this error is correlated to other errors in your manifest. Check if there are some missing dependencies and if all the tags are closed. In my case I had deleted a folder in /res folder, I restored it and that error disappeared.


I had this problem now - I created a new folder under the layout folder which would contain all the xml relate to my "home" page of my app and then another folder that would relate to my "settings" page as I wanted to organise my xml.

However, android only recognises the layout folder for xmls, not the layout/home or layout/settings folder so that is why it was giving me the error.

Thanks to Mazen Kasser answer, he assisted me in figuring this out.


Ran into this recently trying to migrating an existing app to material design. All I had to do to fix it was change the project's Compile SDK Version. File | Project Settings. Select app and pick a Compile SDK version for Lollipop or higher.


I use Intellij IDEA but I think it will also work in Android Studio, can you see the "Event Log" at IDE right bottom corner, did it have some message like that "Android framework is detected in the project Configure", that means you should have a framework configuration. If so, just follow the message link.
In the same way, you can go to "File > Project Structure > Modules" , and then add a Android Facet.

enter image description here

by the way, if I want use a customized namespace like you do, I'll write the resource identifier as my package name as I define the AndroidManifest.xml package attribute of the manifest element, below is my code.

<manifest package="com.my.name.android">
    ...
</manifest>

<RelativeLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/apk/res/com.my.name.android">
</RelativeLayout>

Hope this helps you.


For me Plugin Android Support get Disabled somehow. Enabling Plugins again worked for me.

Settings > Plugins > Android Support

I encountered same problem in opening android React Native Project in Android Studio.

The root cause is I opened the root folder of React Native Project instead of android folder of the React Native Project.

Reopen the project under android folder of React Native Project solved my problem.


  • Go to "Preferences > Languages&Frameworks > Schemas and DTDS"
  • Click "add(+)"
  • Click "apply" and then "ok"

hope it will works.