在Eclipse开发Android版:R.java不会再生 [英] Developing for Android in Eclipse: R.java not regenerating

查看:107
本文介绍了在Eclipse开发Android版:R.java不会再生的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我发现我的R.java从不更新,所以它不包含我的新资源的信息,所以我决定将其删除,并认为Eclipse中会产生一个新的。但是,这并没有发生,而我没有R.java了。我怎么可以再生一个?

I've found out that my R.java is never updated, so it doesn't contain information about my new resources, so I decided to delete it and thought that Eclipse would generate a new one. But that didn't happen, and I don't have R.java now. How can I regenerate one?

我使用Windows  7。

I'm using Windows 7.

从评论之一:这样做的项目的 - >的清除的是什么原因造成的问题,对我来说清洁删除R.java ......以任何理由的。插件未重新生成的文件。

From one of the comments: "Doing Project -> Clean is what caused the problem for me. Cleaning deletes R.java...and for whatever reason the plugin is not regenerating the file."

推荐答案

我发现这发生在我身上带着一个破碎的布局,一切都吹了起来。放松,它就像旧的错误,当你第一次学习编程C本,你忘记了一分号,它产生一个100个错误。许多恐慌,preSS所有的按钮,使事情变得更糟。

I found this happening to me with a broken layout and everything blows up. Relax, it's like that old mistake when you first learned programming C where you forget one semicolon and it generates a hundred errors. Many panic, press all the buttons, and makes things worse.

  • 确保任何事情的研究。链接不破。 修正所有错误XML文件中的。如果在ADKs什么都碎了,研究将不能再生。
  • 如果你不小心碰到了什么东西,创造了进口android.R 在您的活动,删除它
  • 运行项目 - >清除。这将删除并重新生成R和BuildConfig。
  • 确保项目 - >自动构建勾选。如果不正确,通过手动构建它菜单 - >项目 - >建设项目
  • 等待几秒钟的误差消失。
  • 如果它不工作,删除一切的/根/文件夹
  • 里面
  • 如果它仍然不能正常工作,请尝试右键点击你的项目 - > Android的工具 - >修复项目属性
  • 检查您的 *性能文件(在你的应用程序文件夹的根文件夹中),并确保在那里的联系不会中断。
  • 右键点击您的项目>属性>安卓。看项目建设目标和图书馆部分右侧的页面。您的构建目标应与目标在AndroidManifest.xml中。所以,如果它被设置为目标17 AndroidManifest,确保目标名称的是Android 4.2。如果你的图书馆有在基准的X,删除并重新添加库,直到有一个绿色的勾。如果你搬来搬去了一些文件和文件夹可能发生这种情况。
  • Make sure that anything the R. links to is not broken. Fix all errors in your XML files. If anything in the ADKs are broken, R will not regenerate.
  • If you somehow hit something and created import android.R in your activity, remove it.
  • Run Project -> Clean. This will delete and regenerate R and BuildConfig.
  • Make sure Project -> Build Automatically is ticked. If not, build it manually via Menu -> Project -> Build Project .
  • Wait a few seconds for the errors to disappear.
  • If it doesn't work, delete everything inside the /gen/ folder
  • If it still doesn't work, try right-clicking your project -> Android Tools -> Fix Project Properties.
  • Check your *.properties files (in the root folder of your app folder) and make sure that the links in there are not broken.
  • Right-click your project > properties > Android. Look at the Project Build Target and Library sections on the right side of the page. Your Build Target should match the target in your AndroidManifest.xml. So if it's set to target 17 in AndroidManifest, make sure that the Target Name is Android 4.2. If your Library has an X under the reference, remove and re-add the library until there's a green tick. This might happen if you've moved a few files and folders around.

这通常是因为你有一个破损的XML文件。

This usually happens when you have a broken XML file.

  • 检查错误,在你的XML文件,主要是 / RES / 文件夹中
  • 在常见的地方是 /布局/ /价值/ ,特别是如果你改变了其中一个最近
  • 检查的Andr​​oidManifest.xml 。我发现,我经常改变字符串和忘了从的Andr​​oidManifest.xml 修改字符串名称。
  • 检查 Android SDK中内建工具安装。 窗口 - > Android的SDK管理器 - >工具 - > Android SDK中内建工具
  • 确保在更新 Android的SDK工具,也更新了的Andr​​oid SDK平台工具 Android的ADK内置工具。建立静静地失败,如果他们不匹配。
  • 如果您不能找到问题,右键点击/ GEN / - >还原从当地的历史... - >勾R.java - >单击还原。即使它并没有解决问题,将清除掉多余的错误使问题更容易找到。
  • Check errors inside your XML files, mainly within the /res/ folder
  • Common places are /layout/ and /values/, especially if you've changed one of them recently
  • Check AndroidManifest.xml. I find that often I change a string and forget to change the string name from AndroidManifest.xml.
  • Check that Android SDK Build-tools is installed. Window -> Android SDK Manager -> Tools -> Android SDK Build-tools
  • Make sure when you update the Android SDK Tools, you also update the Android SDK Platform-tools and Android ADK Build-tools. Build fails silently if they don't match.
  • If you can't find the issue, right click /gen/ -> Restore from local history... -> tick R.java -> click Restore. Even if it doesn't solve the problem, it will clear out the extra errors to make the problem easier to find.

这篇关于在Eclipse开发Android版:R.java不会再生的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆