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:
所以我尝试了一下Android Studio,因为我真的很喜欢Resharper,并且注意到IDE内置了一些他们的功能。创建了一个默认的新项目后,我添加了一个新的布局文件,并希望更改现有的默认的“hello world”示例布局,并在以下几行中得到一个“URI未注册”错误:
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'").
我还没有对默认生成的项目做什么。我遇到了另一个似乎相关的问题(Intellij Android project schema URI没有注册?)我确实试过了,但是这会导致RelativeLayout(可能还有其他Android相关的东西)不再被识别(错误信息:“无法找到元素RelativeLayout”的声明”)。
Any ideas on how to solve this problem?
对如何解决这个问题有什么想法吗?
116
You are having this issue because you are at the wrong destination! The correct directory for the Layout resource file has to be under "res-layout" not "res-all-layout"
你有这个问题是因为你在错误的目的地!布局资源文件的正确目录必须在“res-layout”之下,而不是“res-all-layout”
42
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.
对我来说,这是因为我使用了一个调试和发布构建版本。我添加了新的文件夹src/debug/res/layout/some_layout。xml文件是手动的,它不识别URI。我将构建版本切换到release,然后返回到debug。这导致Android Studio重新加载一些东西,错误消失了。
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.
编辑:也检查你有正确的文件名。通过添加调试AndroidManifest,我再次遇到了这个问题。xml,但错误地将其命名为AndroidManifest.xml.xml。
36
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.
我用的是Intellij IDEA,但是我认为它也可以用在Android Studio中,你能看到IDE的“事件日志”在右下角吗,它有没有像“在project Configure中检测到Android框架”这样的信息,这意味着你应该有一个框架配置。如果是的话,请遵循消息链接。同样,您可以转到“File > Project Structure > Modules”,然后添加一个Android方面。
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.
顺便说一下,如果我想像您那样使用定制的名称空间,我将在定义AndroidManifest时将资源标识符作为包名。清单元素的xml包属性,下面是我的代码。
...
Hope this helps you.
希望这能帮助你。
15
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! :)
这个问题突然出现在我面前,没有任何原因。我刚刚关闭了Android Studio中的所有选项卡,重新打开了有问题的xml文件。问题解决了!:)
5
Its a plugins problems.
这是一个插件的问题。
then it will automatic restart your studio and works will fine.
然后它将自动重新启动你的工作室和工作将会很好。
hope it will works.
希望它能工作。
4
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
原来我正在编辑xml的调试版本,为了修复它,只需关闭有错误的选项卡并重新打开它
3
i had the same error. I solved it by importing the project again to the android studio.
我犯了同样的错误。我通过再次将项目导入android studio解决了这个问题。
2
My problem was that my folders were structured as:
我的问题是我的文件夹结构是:
MyProject/ res/ layout/ main.xml layout-land/ main.xml
MyProject / res / layout / main。xml layout-land / main。xml
(My Slayout-land
folder was in my layout
folder)
(我的slaot -land文件夹在我的布局文件夹中)
I changed the structure to this and it worked for me:
我把结构改成了这个,它对我起了作用:
MyProject/ res/ layout/ main.xml layout-land/ main.xml
MyProject / res / layout / main。xml layout-land / main。xml
I hope that this helps!
我希望这能有所帮助!
2
Don't know the reason behind this error but I found out this somewhere and it solved my problem.
我不知道这个错误的原因,但我在某个地方发现了它,它解决了我的问题。
2
For me Plugin Android Support
get Disabled somehow. Enabling Plugins again worked for me.
对于me插件,Android支持以某种方式被禁用。启用插件再次对我起作用。
Settings > Plugins > Android Support
1
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.
有时这个错误与清单中的其他错误相关。检查是否有一些缺失的依赖项,以及是否关闭了所有标记。在我的例子中,我删除了/res文件夹中的一个文件夹,我恢复了它,那个错误消失了。
1
For me, the offending xml files were missing the header line...
对我来说,违规的xml文件缺少了标题行……
Adding that fixed it.
增加固定它。
1
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.
再来一次,现在真正起作用的是在建筑内部添加一些垃圾。然后尝试同步。当它失败时,清除垃圾并重新同步。索引后,它的工作原理。
1
hope it will works.
希望它能工作。
1
For me, I was missing compile 'com.android.support:cardview-v7:25.0.1'
in the build.gradle (Module app)
对我来说,我错过了编译“com.android.support:cardview-v7:25.0.1”。gradle(模块应用)
0
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.
Android Studio中的新构建系统创建一个构建文件夹。这个文件夹以及gradle文件夹上的代码检查barfs。在运行代码检查时,这些文件夹应该被忽略。
I have raised an issue with the Android Studio team at:
我已经向Android Studio团队提出了一个问题:
https://code.google.com/p/android/issues/detail?id=56415
https://code.google.com/p/android/issues/detail?id=56415
0
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.
我现在遇到了这个问题——我在布局文件夹下创建了一个新的文件夹,它包含了我的应用程序的“home”页面,然后是另一个与我的“设置”页面相关的文件夹,因为我想要组织我的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.
然而,android只识别用于xmls的布局文件夹,而不是布局/家庭或布局/设置文件夹,所以它给了我错误的原因。
Thanks to Mazen Kasser answer, he assisted me in figuring this out.
多亏了Mazen Kasser的回答,他帮助我解决了这个问题。
0
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.
最近,我在尝试将现有的应用程序移植到材料设计中。我所要做的就是修改项目的编译SDK版本。文件|项目设置。选择app,选择Lollipop或更高版本的编译SDK版本。
0
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.
这里提到的任何解决办法都对我有帮助。我把我的问题贴出来,以防对任何人都有帮助。在我的例子中,错误是使用数据绑定发生的。似乎创建了使用数据绑定的xml中介。如果尝试打开错误时出现错误,将显示带有“未注册URI”的中间xml,而不是打开带有错误的正确xml。
0
For most of the time it will be solved by Rebuild Project
在大多数情况下,重建项目将解决这个问题
0
For me I put an xml file in the values folder manually. Then the problem shows. I also noticed that the xml file name and the array-name in its I gave are same. So, I rename the xml file name and restrat Android studio.
对于我来说,我将一个xml文件手工放入值文件夹。然后显示的问题。我还注意到我给出的xml文件名和数组名是相同的。因此,我重命名了xml文件名并限制了Android studio。
The Problem has Gone!
问题了!
0
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.
我遇到了这个问题,对我来说,这是因为在Android Studio之外创建和操作资源文件。我按照说明通过Android Studio创建新的资源文件和文件夹,解决了这个问题。您需要创建一个新的资源文件而不是目录。如果需要,它将允许您指定或创建一个目录。如果您正在为不同版本的布局创建目录,请在顶部输入信息,包括要复制到新文件夹的资源文件的名称,并选择版本并输入Android版本。它将创建包含资源副本的适当目录。
0
Another suggestion, which was the solution for me: I got the error in the line
另一个建议,对我来说是解决办法:我得到了直线上的错误
in the values.xml file that was automatically generated during the build process.
的值。在构建过程中自动生成的xml文件。
It was solved by adding the android
prefix in the styles.xml file.
通过在样式中添加android前缀来解决这个问题。xml文件。
had to be changed to
必须改成?
0
Close the Project and Import It Back Again.
关闭项目并再次导入它。
It Works out!!!
它工作了! ! !
0
In Android Studio 3.1.2 this error occurs due to Wrong validation of the cache memory.,
在Android Studio 3.1.2中,由于缓存内存验证错误而出现此错误。
Go to Project folder and delete all the contents in .idea folder
转到项目文件夹,删除。idea文件夹中的所有内容
This will delete the cache memory and reloading the project will create new cache memory folder and makes it good to go.,
这将删除缓存内存,重新加载项目将创建新的缓存内存文件夹,使其运行良好。
-2
Try to Install the android tracker plugin. you will find it on the studio.
尝试安装android跟踪器插件。你可以在演播室找到它。
Restart the studio
重新启动工作室