android r.java不会更新

发布于 2024-09-08 22:56:30 字数 468 浏览 6 评论 0原文

我用谷歌搜索了很多,找到了可能导致这个问题的各种提示。这个论坛里有很多人,但没有任何效果。

我在3台不同的机器(xp、macos雪豹、leopard)上从头开始安装了sdk,但总是出现同样的问题,即使是android sdk中的示例代码也无法编译。 经过几个小时的查看 xml 文件后,我发现,当我从字符串中删除 ' 时,sdk 的示例代码将进行编译。 只要 R.java 文件中不需要更改,新项目也是如此。 当我尝试使用 findViewByID 添加按钮时,我收到字段 R.id 无法解析的错误。该项目没有进行其他更改。

正如之前提到的,我尝试了各种方法,包括: 清理项目,重建 重新启动日食 更新sdk(尽管我安装了新的sdk) 没有大写字母 ... 在干净的机器上安装sdk,最新的eclipse classic

我不认为这是代码本身的问题,因为即使是sdk提供的示例代码如果不从xml中删除'也无法编译。

请有人提供一些提示和想法,下一步该去哪里?

I googled a lot to find various hints what could cause this problem. Many of them on this forum, but nothing works.

I installed the sdk from scratch on 3 different machines (xp, macos snow leopard, leopard) and always the same problem, that even the sample code in the android sdk doesn't compile.
After hours of looking through the xml files I recognized, that when I remove ' from strings the sample code of the sdk will compile.
So does a new project, as long there is no change needed in the R.java file.
As soon as I try to add a button with findViewByID, I get the error that the field R.id cannot be resolved. No other changes were done to the project.

As mentioned before I tried various things, including:
clean project, rebuild
restart eclipse
update sdk (even tough I installed the new sdk)
no uppercase letters
...
Install sdk, latest eclipse classic on a clean machine

I don't think it's an issue of the code itself, because even the sample code provided by the sdk doesn't compile without removing ' from the xml.

Please somebody has some hints and ideas where to look next please?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

韶华倾负 2024-09-15 22:56:30

在eclipse中打开“问题”窗口,如果任何xml文件中有任何问题,R.java将不会生成。

如果xml文件中有单引号,则应将其替换为双引号。 XML 标准是所有属性值都用双引号括起来,而不是单引号。

无效

<?xml version='1.0' encoding='utf-8' ?>
<resources>
  <string name='some_name'>value</string> 
</resources>

有效

<?xml version="1.0" encoding="utf-8" ?>
<resources>
  <string name="some_name">value</string> 
</resources>

open the "problems" window in eclipse, if there are any issues in any of the xml files, R.java will not generate.

if there are single quotes in the xml files, they should be replaced with double quotes. the XML standard is that all attribute values be surrounded by double quotes, not single quotes.

Invalid

<?xml version='1.0' encoding='utf-8' ?>
<resources>
  <string name='some_name'>value</string> 
</resources>

Valid

<?xml version="1.0" encoding="utf-8" ?>
<resources>
  <string name="some_name">value</string> 
</resources>
薔薇婲 2024-09-15 22:56:30

查看 Eclipse 中出现问题的最简单方法是转到“Window”>“Show View”>“Other”>“General”>“Error Log”

The easiest way to see what went wrong in Eclipse is to go to Window>Show View>Other>General>Error Log

堇年纸鸢 2024-09-15 22:56:30

如果您使用的是 Eclipse,请在项目中的 Package Explorer 下找到 res\layout\activity_(activity name).xml 并右键单击并使用文本编辑器打开它。在 TextView: 下添加

android:id = "@+id/button_id"

并清理重建您的项目。使用findViewById(R.id.button_id)。

If you are using Eclipse, under Package Explorer, in your project, find res\layout\activity_(activity name).xml and right click and open it with text editor. Add under TextView:

android:id = "@+id/button_id"

and clean rebuild your project. Use findViewById(R.id.button_id).

不念旧人 2024-09-15 22:56:30

对于 Eclipse,请确保选择菜单 -> 项目 -> 自动构建

然后删除gen/中的所有文件。它们应该自动重新生成。这将强制更新 R.java。

With eclipse, make sure Menu->Project->Build automatic is selected.

Then delete all the files in gen/. They should be automatically regenerated. This will force an update to R.java.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文