在 Android Studio 中构建项目时出错“错误:找不到与给定名称匹配的资源(在____处,值为“@drawable/<name>") [英] Error Building Project in Android Studio &quot;Error: No resource found that matches the given name (at ____ with value &#39;@drawable/&lt;name&gt;&#39;)

查看:39
本文介绍了在 Android Studio 中构建项目时出错“错误:找不到与给定名称匹配的资源(在____处,值为“@drawable/<name>")的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在 Google、stackoverflow 和其他 android 编程网站上搜索过,很多人都对那些将文件从一个文件夹放错位置的人提出了建议,等等.但没有一个能说明我面临的问题.

I've searched all over Google, stackoverflow and other android programming websites, many have suggestions for people who have misplaced files from one folder to another and so forth.. But none that illustrate the problem I'm facing.

它不是像此处那样的损坏文件 因为我试过没有成功.

It's not a corrupt file as in the case here as I tried this with no success.

我面临的错误是类似的:

The error I'm facing is similar though:

[debug] C:\Users\Name\AppData\Local\Temp\android_manifest_copy6264790980678653632tmp\AndroidManifest.xml:11: error: Error: No resource found that matches the given name (at 'icon' with value '@drawable/ic_launcher').

类似地,这发生在@string 元素、@style 元素和另一个@string 中,示例如下:

Similarly, this is happening with an @string element, @style element and another @string, examples below:

'@string/app_name'
'@style/AppTheme'
'@string/app_name'

我注意到的一件事,来自 Eclipse 的世界,我无法在 Android Studio 中解释这种行为.在我的主"项目文件夹中,一切都存在并正确构建以进行调试.似乎 Android Studio 正在尝试构建一个调试"文件夹,该文件夹在运行构建">重建项目"时不会构建.

One thing that I have noticed, and coming from the world of Eclipse, I cannot explain this behavior in Android Studio.. In my 'main' project folder, everything exists and builds correctly for debugging. It seems that Android Studio is trying to build off of a 'debug' folder, which will not build when running 'Build' > 'Rebuild Project'.

有谁知道我可以在哪里放置这些丢失的文件来构建项目?或者这是其他什么问题?

Does anyone know where I can place these missing files to get the project to build? Or is this some other problem?

推荐答案

好吧,所以在尝试不同的方法(重命名特定文件 [即那些有问题的文件],重命名文件夹内的文件夹后重建应用程序数小时后大惊小怪)build 文件夹等)我最终决定去寻找问题的根源,看看它是否像其他 IDE 一样工作.确实如此,这就是我执行修复的方式:

Alright, so after fussing with the rebuild for hours trying different methods (renaming particular files [i.e. those with the problems], rebuilding the app after renaming folders inside the build folder, etc) I finally decided that I would go to the source of the problem and see if it worked like other IDE's. Indeed it did, this is how I performed the fix:

  1. 找到问题的位置 - 对我来说,我遇到的所有四个错误都在项目的build"文件夹中.
  2. 关闭项目的所有打开实例
  3. 当项目关闭时,从 Windows 资源管理器(或其他,如果您使用不同的操作系统)重命名此文件夹(即,如果文件夹名称为build",则将其重命名为build.old")
  4. 再次打开项目
  5. 转到构建">重建项目"

你这样做应该不会有任何问题,就像我一样.

You should not have any issues doing this, like I did.

规格:

  • IDE 平台:Android Studio
  • IDE 版本:Android Studio(I/O 预览版)0.2.2
  • JRE:1.7.0_25

这篇关于在 Android Studio 中构建项目时出错“错误:找不到与给定名称匹配的资源(在____处,值为“@drawable/<name>")的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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