Xamarin的Android资源文件中未找到 [英] Xamarin Android Resource file not found

查看:732
本文介绍了Xamarin的Android资源文件中未找到的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Visual Studio中建立一个Android应用程序。当我尝试构建应用程序的资源文件夹引用的项目,我得到两个错误之一。

I am building an Android App in Visual Studio. When I try to build the app referencing items in the Resources folder, I get one of two errors.

如果我自序Resource.Layout。[ID]或 。Resource.Id [ID]与命名空间为我的项目,我得到这个错误:

If I preface "Resource.Layout.[Id]" or "Resource.Id.[Id]" with the namespace for my project, I get this error:

类型或命名空间名称资源并不在命名空间存在[应用空间]'(是否缺少程序集引用?)

The type or namespace name 'Resource' does not exist in the namespace '[app namespace]' (are you missing an assembly reference?)

如果我不前言电话与我的命名空间的资源,它尝试访问默认的Android .Resource类和我得到这个错误:

If I don't preface the call to Resource with my namespace, it tries to access the default Android.Resource class and I get this error:

Android.Resource.Layout不包含[AXML文件]'的定义

'Android.Resource.Layout' does not contain a definition for '[axml file]'

有没有人碰到这个错误运行之前?我一直在寻找了一会儿,不能拿出任何东西,这似乎是错误的。该Resource.Designer文件存在。我已经删除了它,让它获得再生。该ID在资源文件,该项目只是没有认识到,资源类是那里。

Has anyone run across this error before? I've been searching for a while and cannot come up with anything that seems to be wrong. The Resource.Designer file exists. I've deleted it and let it get regenerated. The Ids are in the Resource file, the project just doesn't recognize that the resource class is there at all.

本来,这个应用程序的命名空间中的Android结束。认为可能是问题的一部分,我已经改成了_Android和AndroidApp,包括改变在项目属性的默认命名空间,并改变每个文件的命名空间声明。但是,此错误通过每个变化仍然存在。

Originally, the namespace for this application ended in "Android". Thinking that may be part of the issue, I've changed it to "_Android" and "AndroidApp", including changing the default namespace in the project properties and changing the namespace declaration in each file. However, this error persists through each change.

推荐答案

这可能当你添加一个新的文件和Visual Studio将它设置为发生错误的生成操作。我知道这已经多次发生在我可以花年龄试图弄清楚怎么回事。如果右键单击该文件,看生成操作。这应该被设置到Android资源。希望它能帮助

This might happen when you add a new file and Visual studio sets it to the wrong build Action. I know this has happened me multiple times and can spend ages trying to figure out what going on. If you right click the file and see the Build action. this should be set to Android Resource. Hope it helps

这篇关于Xamarin的Android资源文件中未找到的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆