简体   繁体   English

R.java没有更新

[英]R.java not updating

I am unable to build my app because R.java will not update the ids. 我无法构建我的应用程序,因为R.java不会更新ID。 I updated the id in main.xml but the old values remain. 我更新了main.xml的id但旧的值仍然存在。 This obviously prevents it from building. 这显然阻止了它的建立。 Is there any way to fix this? 有没有什么办法解决这一问题? Could I manually update R.java by renaming the variables and leaving the references untouched, or is this unsafe? 我可以通过重命名变量并保持引用保持不变来手动更新R.java ,还是不安全? There are no problems other than the 3 lines of code posted below and unused variable warnings. 除了下面发布的3行代码和未使用的变量警告之外,没有其他问题。

StopwatchAppActivity.java: StopwatchAppActivity.java:

pauseBtn = (Button)   findViewById(R.id.pause_btn);
resetBtn = (Button)   findViewById(R.id.reset_btn);
timeDisp = (TextView) findViewById(R.id.time_tv);

main.xml: main.xml中:

<TextView
    android:id="@+id/time_tv"
    ... />

<Button
    android:id="@+id/pause_btn"
    ... />

<Button
    android:id="@+id/reset_btn"
    ... />
  1. Check all of your XML, 检查所有XML,
  2. Project -> Clean, 项目 - >清洁,
  3. Right click -> Fix Project Properties, 右键单击 - >修复项目属性,
  4. Repeat. 重复。
  5. Maybe try restarting Eclipse 也许尝试重启Eclipse

My panic list for R generation problems 我对R代问题的恐慌清单

Jest clean the project and rebuild it still if you get the same problem delete the R.java from the eclipse it will recreated automatically with the new values. Jest清理项目并重建它仍然如果你遇到同样的问题从eclipse中删除R.java它将使用新值自动重新创建。

Note: check R.java package imported in your project. 注意:检查项目中导入的R.java包。 If it's android.R jest replace with your package name.R; 如果它是android.R jest替换你的包名.R;

When you make a Project/Clean it will not run properly if you have a resource with an error in its name, like for example an image with an upper case letter. 当您创建项目/清理时,如果您的名称中包含错误的资源,则它将无法正常运行,例如带有大写字母的图像。 Loot at the console error messages after the Clean. 清除后,在控制台错误消息处消除。

remove unwanted files from project and remove unwanted code from menifest file . 从项目中删除不需要的文件,并从清单文件中删除不需要的代码。 R.java will update automatically :) R.java会自动更新:)

I had the same problem. 我有同样的问题。 The only thing that finally solved it was deleting the id text that had been autogenerated by using the graphical layout. 最终解决它的唯一问题是删除使用图形布局自动生成的id文本。 As soon as I manually typed the "@+id/... the .java file recognised it. 一旦我手动输入“@ + id / ... .java文件识别它。

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

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