热门标签 | HotTags
当前位置:  开发笔记 > 编程语言 > 正文

为什么AndroidStudio报告“URI未注册”?-WhyisAndroidStudioreporting“URIisnotregistered”?

SoIvegivenAndroidStudioatry,becauseIreallylikeResharperandnoticedthattheIDEhadsom

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?

对如何解决这个问题有什么想法吗?

26 个解决方案

#1


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”

#2


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。

#3


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.

enter image description here

我用的是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.

希望这能帮助你。

#4


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


5  

Its a plugins problems.

这是一个插件的问题。

  1. Restart Your android studio.
  2. 重启你的android工作室。
  3. It will show a pop window for enable plugins
  4. 它将显示一个支持插件的弹出窗口
  5. click on enable plugins and then click on Okay.
  6. 单击“启用插件”,然后单击“确定”。

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

然后它将自动重新启动你的工作室和工作将会很好。

hope it will works.

希望它能工作。

#6


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的调试版本,为了修复它,只需关闭有错误的选项卡并重新打开它

#7


3  

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

我犯了同样的错误。我通过再次将项目导入android studio解决了这个问题。

#8


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!

我希望这能有所帮助!

#9


2  

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"
  • 点击“android”和“apply”,点击“ok”

#10


2  

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

对于me插件,Android支持以某种方式被禁用。启用插件再次对我起作用。

Settings > Plugins > Android Support

#11


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文件夹中的一个文件夹,我恢复了它,那个错误消失了。

#12


1  

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

对我来说,违规的xml文件缺少了标题行……


Adding that fixed it.

增加固定它。

#13


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.

再来一次,现在真正起作用的是在建筑内部添加一些垃圾。然后尝试同步。当它失败时,清除垃圾并重新同步。索引后,它的工作原理。

#14


1  

  • Go to "Preferences > Languages&Frameworks > Schemas and DTDS"
  • 点击“首选项>语言和框架>模式和DTDS”
  • Click "add(+)"
  • 点击“添加(+)”
  • Click "apply" and then "ok"
  • 点击“应用”,然后点击“确定”

hope it will works.

希望它能工作。

#15


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(模块应用)

#16


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

#17


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的回答,他帮助我解决了这个问题。

#18


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版本。

#19


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。

#20


0  

For most of the time it will be solved by Rebuild Project

在大多数情况下,重建项目将解决这个问题

#21


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!

问题了!

#22


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版本。它将创建包含资源副本的适当目录。

#23


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

必须改成?


#24


0  

Close the Project and Import It Back Again.

关闭项目并再次导入它。

It Works out!!!

它工作了! ! !

#25


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.,

这将删除缓存内存,重新加载项目将创建新的缓存内存文件夹,使其运行良好。

#26


-2  

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

尝试安装android跟踪器插件。你可以在演播室找到它。

Restart the studio

重新启动工作室


推荐阅读
  • 本文介绍了使用kotlin实现动画效果的方法,包括上下移动、放大缩小、旋转等功能。通过代码示例演示了如何使用ObjectAnimator和AnimatorSet来实现动画效果,并提供了实现抖动效果的代码。同时还介绍了如何使用translationY和translationX来实现上下和左右移动的效果。最后还提供了一个anim_small.xml文件的代码示例,可以用来实现放大缩小的效果。 ... [详细]
  • Spring源码解密之默认标签的解析方式分析
    本文分析了Spring源码解密中默认标签的解析方式。通过对命名空间的判断,区分默认命名空间和自定义命名空间,并采用不同的解析方式。其中,bean标签的解析最为复杂和重要。 ... [详细]
  • Android开发实现的计时器功能示例
    本文分享了Android开发实现的计时器功能示例,包括效果图、布局和按钮的使用。通过使用Chronometer控件,可以实现计时器功能。该示例适用于Android平台,供开发者参考。 ... [详细]
  • 本文讨论了如何使用Web.Config进行自定义配置节的配置转换。作者提到,他将msbuild设置为详细模式,但转换却忽略了带有替换转换的自定义部分的存在。 ... [详细]
  • 本文介绍了Android中的assets目录和raw目录的共同点和区别,包括获取资源的方法、目录结构的限制以及列出资源的能力。同时,还解释了raw目录中资源文件生成的ID,并说明了这些目录的使用方法。 ... [详细]
  • Activiti7流程定义开发笔记
    本文介绍了Activiti7流程定义的开发笔记,包括流程定义的概念、使用activiti-explorer和activiti-eclipse-designer进行建模的方式,以及生成流程图的方法。还介绍了流程定义部署的概念和步骤,包括将bpmn和png文件添加部署到activiti数据库中的方法,以及使用ZIP包进行部署的方式。同时还提到了activiti.cfg.xml文件的作用。 ... [详细]
  • 开发笔记:(002)spring容器中bean初始化销毁时执行的方法及其3种实现方式
    篇首语:本文由编程笔记#小编为大家整理,主要介绍了(002)spring容器中bean初始化销毁时执行的方法及其3种实现方式相关的知识,希望对你有一定的参考价值。 ... [详细]
  • 这两天用到了ListView,写下遇到的一些问题。首先是ListView本身与子控件的焦点问题,比如我这里子控件用到了Button,在需要ListView中的根布局属性上加上下面的这一个属性:and ... [详细]
  • 四、连接屏幕流各位读者好!我们已经到了应用开发的一个重要阶段——连接屏幕。如您所知,我们在上一章 ... [详细]
  • Java序列化对象传给PHP的方法及原理解析
    本文介绍了Java序列化对象传给PHP的方法及原理,包括Java对象传递的方式、序列化的方式、PHP中的序列化用法介绍、Java是否能反序列化PHP的数据、Java序列化的原理以及解决Java序列化中的问题。同时还解释了序列化的概念和作用,以及代码执行序列化所需要的权限。最后指出,序列化会将对象实例的所有字段都进行序列化,使得数据能够被表示为实例的序列化数据,但只有能够解释该格式的代码才能够确定数据的内容。 ... [详细]
  • 如何使用Java获取服务器硬件信息和磁盘负载率
    本文介绍了使用Java编程语言获取服务器硬件信息和磁盘负载率的方法。首先在远程服务器上搭建一个支持服务端语言的HTTP服务,并获取服务器的磁盘信息,并将结果输出。然后在本地使用JS编写一个AJAX脚本,远程请求服务端的程序,得到结果并展示给用户。其中还介绍了如何提取硬盘序列号的方法。 ... [详细]
  • MyBatis多表查询与动态SQL使用
    本文介绍了MyBatis多表查询与动态SQL的使用方法,包括一对一查询和一对多查询。同时还介绍了动态SQL的使用,包括if标签、trim标签、where标签、set标签和foreach标签的用法。文章还提供了相关的配置信息和示例代码。 ... [详细]
  • 本文讨论了如何在codeigniter中识别来自angularjs的请求,并提供了两种方法的代码示例。作者尝试了$this->input->is_ajax_request()和自定义函数is_ajax(),但都没有成功。最后,作者展示了一个ajax请求的示例代码。 ... [详细]
  • 【CTF 攻略】第三届 SSCTF 全国网络安全大赛—线上赛 Writeup
    【CTF 攻略】第三届 SSCTF 全国网络安全大赛—线上赛 Writeup ... [详细]
  • 03Spring使用注解方式注入
    基于注解的DI注入1.导包环境搭建:导入aop包(spring-aop-4.1.6.RELEASE.jar)2.创建类3.创建spring.xml配置文件(必须在src目录下)该配 ... [详细]
author-avatar
你们聊交给我
这个家伙很懒,什么也没留下!
PHP1.CN | 中国最专业的PHP中文社区 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved | 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有