[英]Error Building Project in Android Studio "Error: No resource found that matches the given name (at ____ with value '@drawable/<name>')
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. 我搜遍了谷歌,stackoverflow和其他Android编程网站,很多人都建议那些把文件从一个文件夹放到另一个文件夹的人等等......但没有一个能说明我面临的问题。
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').
Similarly, this is happening with an @string element, @style element and another @string, examples below: 类似地,这发生在@string元素,@ style元素和另一个@string,下面的示例:
'@string/app_name'
'@style/AppTheme'
'@string/app_name'
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. 我注意到的一件事,来自Eclipse的世界,我无法在Android Studio中解释这种行为。在我的“主”项目文件夹中,一切都存在并且正确构建用于调试。 It seems that Android Studio is trying to build off of a 'debug' folder, which will not build when running 'Build' > 'Rebuild Project'.
似乎Android Studio正试图建立一个'debug'文件夹,在运行'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?
或者这是另一个问题吗?
Alright, so after fussing with the rebuild for hours trying different methods (renaming particular files [ie 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. 好吧,所以在重建几个小时后尝试不同的方法(重命名特定文件[即那些有问题],在重命名构建文件夹内的文件夹后重建应用程序等)我终于决定我会去的源头问题,看看它是否像其他IDE一样工作。 Indeed it did, this is how I performed the fix:
确实如此,这是我执行修复的方式:
You should not have any issues doing this, like I did. 像我一样,你不应该有任何问题。
Specifications: 产品规格:
My problem is about @drawable/img_1
, the pic is JPEG format, while it's extension name is png, I force to rename it jpg extension. 我的问题是关于
@drawable/img_1
,pic是JPEG格式,而它的扩展名是png,我强制重命名为jpg扩展名。 Then it builds successfully. 然后它成功构建。
If anyone is using Gradle and sees this it's good to remind about the convention directory structure. 如果有人正在使用Gradle并且看到这个,那么最好提醒一下约定目录结构。
For Gradle you have to put your resources in src/main/res. 对于Gradle,您必须将资源放在src / main / res中。 I migrated a project to Gradle and got the said error when I hadn't moved the res/ directory from the old structure.
当我没有从旧结构移动res /目录时,我将一个项目迁移到Gradle并得到了所述错误。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.