简体   繁体   English

尝试访问android项目资源时出现“无法查找符号”错误

[英]“Cannot Find Symbol” error when trying to access android project resources

I'm learning how to program for Android atm. 我正在学习如何为Android atm编程。 Following a tutorial for graphics , I've run into a problem; 按照图形教程 ,我遇到了一个问题; Attempting to access the image I've placed in the project resources renders the error "Cannot Find Symbol". 尝试访问我放置在项目资源中的图像会出现错误“无法找到符号”。 Attempting to follow the advice NetBeans provided me with, I placed the image in the same package as the file I was writing, which rendered the same error telling me that there was nothing specifically where I'd place the file. 试图遵循NetBeans提供给我的建议,我将图像放在与我正在编写的文件相同的包中,这会产生同样的错误,告诉我没有具体的地方放置文件。

Since a picture speaks a thousand words, here's two pictures of what I'm talking about: 由于一张图片说千言万语,这里有两张我正在谈论的图片:

在此输入图像描述

Had to stitch the images together because StackOverFlow wouldn't let me post images or more than 2 links. 不得不将图像拼接在一起因为StackOverFlow不允许我发布图像或超过2个链接。

你应该制作drawable文件夹而不是图像,并将图像放在drawable文件夹中并作为

R.drawable.your_icon_name

I was having the same problem at one point. 我一度遇到同样的问题。

To fix it I did a clean and build on the project and it gave me a new error 为了解决这个问题,我做了一个干净的工作并在项目上构建,它给了我一个新的错误

res\\drawable\\sunBLU.png Invalid file name: must contain only [a-z0-9_.] res \\ drawable \\ sunBLU.png文件名无效:必须只包含[a-z0-9_。]

so I renamed my image with all lowercase letters, changed my code to match and did another clean and build. 所以我用全部小写字母重命名了我的图像,改变了我的代码以匹配并做了另一个干净和构建。 now my program works. 现在我的程序工作。 Turns out it will only let you use lowercase letters in a image file name. 原来它只允许你在图像文件名中使用小写字母。

hope this helps other people 希望这有助于其他人

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM