简体   繁体   English

R.java的android eclipse问题

[英]android eclipse problem with R.java

Suddenly my Android app is compiling with loads of errors in Eclipse. 突然,我的Android应用正在编译Eclipse中的大量错误。 When I use Project-Clean the console shows it processing until 'Writing symbols for class R' then it pauses for around a minute and finishes with 'Nothing to pre compile' This behaviour follows adding several new strings to my strings.xml and replacing strings in the code with :- 当我使用Project-Clean时,控制台会对其进行处理,直到“为R类编写符号”,然后暂停约一分钟,并以“无须预编译”结束。此行为是在我的strings.xml中添加了几个新字符串并替换了字符串之后在代码中:

getResources().getString(R.string.name of string); getResources()。getString(R.string.name of string);

Any ideas? 有任何想法吗? Would it be safe to delete the R.java file to force it to rebuild perhaps? 删除R.java文件以强制重建也许是安全的吗?

I faced a similar issue. 我遇到了类似的问题。 I had missed putting a plus sign in android:id="@+id/GoTo". 我错过了在android:id =“ @ + id / GoTo”中加一个加号。 Everything was fine after I put back the missing plus sign, cleaned and rebuilt the project. 在我放回丢失的加号,清理并重建项目后,一切都很好。

Check if you import the right R file. 检查是否导入正确的R文件。 It should be your projects file, not android.R . 它应该是您的项目文件,而不是android.R

Maybe your listing is not exact code but if it is, then resources names can't contain spaces. 也许您的清单不是确切的代码,但是如果是,则资源名称不能包含空格。 (I am talking about R.string.name of string ) (我说的R.string.name of string

当您在strings.xml中更改某些内容以保存该文件并重新构建后,当您使用eclipse时非常重要!如果您选中了自动构建选项,那么如果不选择CTRL + S就足够了,那么必须手动重新构建您的R.strings值未进行喷射更新

This is my currently todo list when I have that kind of problem: 当我遇到这种问题时,这是我当前的待办事项清单:

  1. Refresh main project 刷新主项目
  2. Clean 清洁
  3. Build All 全部建立

if it wont work again. 如果它不会再次工作。 Close Eclipse -> repeat from 1. 关闭Eclipse->从1开始重复。

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

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