NetBeans 中的 Android 项目中缺少 R.java

发布于 2024-11-09 15:20:50 字数 375 浏览 0 评论 0原文

我正在为 AP 计算机科学的一个项目做这个。

基础知识:
Mac OS X 10.5.8
NetBeans 7.0
Android SDK 3.0(级别 11)

因此,我正在 NetBeans 中尝试一些 Android API 演示(相对于 Eclipse,我更喜欢它),并且我使用样本\android-11\ApiDemos\ 作为源代码。 R.java 文件未生成并且“包 R 不存在”。我查看了其他答案,他们说清理并构建项目,但该选项在 NetBeans 中显示为灰色(因此只有“清理”和“构建”选项)。在切换到 Eclipse 之前我应该​​尝试什么?如果我需要更改操作系统,我还有一台运行 Windows 7 的计算机。谢谢!

I'm doing this for a project in AP Computer Science.

Basics:
Mac OS X 10.5.8
NetBeans 7.0
Android SDK 3.0 (Level 11)

So I'm trying out some of the Android API Demos in NetBeans (I prefer it over Eclipse) and I'm using samples\android-11\ApiDemos\ for the source. The R.java file is not generating and "package R does not exist". I've looked at other answers, and they say to Clean and Build the Project, but that option is grayed out in NetBeans (so are just the "Clean" and "Build" options). Any ideas on what I should try before I switch to Eclipse? I also have a computer running Windows 7 if I need to change the OS. Thanks!

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

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

发布评论

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

评论(8

↙厌世 2024-11-16 15:20:50

右键单击您的项目并点击构建。它将为您生成缺少的 R 类。至少在 Netbeans 7.1 中对我来说是这样

Right-click your project and hit build. It will generate the missing R class for you. At least it did for me in Netbeans 7.1

感情洁癖 2024-11-16 15:20:50

只需右键单击该项目,选择“更新损坏的项目”命令,然后“构建”就不再是灰色的了。搭建起来,OK!!

右键菜单命令

Just right-click on the project, select the "Update broken project" command, then "Build" is not gray no longer. Build it, OK!!

The right-click menu command

送君千里 2024-11-16 15:20:50

我遇到了同样的问题,但我所做的只是“清理和构建”,然后由 Netbeans 创建 R 文件(运行 7.1)。

我必须在我的 Windows 7 电脑上以管理员身份运行 netbeans,然后它才能构建 R 文件。如果您要将项目保存到“安全”的位置,请确保 Netbeans 获得读取/写入/编辑该位置的所有必要权限

I had the same problem, but all I did was a "Clean and Build", and then the R file was created by Netbeans (running 7.1).

I had to run netbeans as administrator on my Windows 7 pc before it could build the R file. If you're saving the project to somewhere "secured", make sure that Netbeans gets all the neccessary rights to read/write/edit that location

鸩远一方 2024-11-16 15:20:50

获取 NetBeans 的 Android 插件,然后您将能够打开这些项目并使用它们。项目主页是 http://www.nbandroid.org/

可能需要一些初始步骤。在工具 | 设置 SDK 位置选项|杂项 |安卓。然后检查您的项目是否设置了一些构建目标(选择项目,右键单击并转到项目属性)。设置构建目标后,插件将(重新)生成构建脚本和所需的 .properties 文件。然后你就可以运行构建了。

-拉迪姆

Get Android plugin for NetBeans and then you will be able to open these project and play with them. The project home page is http://www.nbandroid.org/

Some initial steps may be needed. Set up SDK location in Tools | Options | Misc | Android. Then check that your project has some build target set in (select project, r-click and go to project properties). Once the build target is set plugin will (re-)generate build script and required .properties files. You'll be able to run build then.

-Radim

若言繁花未落 2024-11-16 15:20:50

可能会发生一些事情,但大多数人会发生的是:

  1. 错误使 R 无法构建
  2. R 是未知的,他们尝试通过导入包来修复错误
  3. 现在 java 文件中存在“导入 R.id”或其他内容
  4. ...
  5. 损失

另外,这可能只是第一点,设置问题(明显损坏、错误的项目道具或类似的东西)使 R 无法生成,然后你就不会拥有 R 了。

但实际上,我我见过一些人们执行第 3 点的例子。

Several things could be going on, but what happens to most people is:

  1. an error makes R not build
  2. R is unknown, they try to fix the error by importing packages
  3. There is now a "import R.id" or something in the java files
  4. ...
  5. Loss

Also, it could just be point one, that a problem with the setup (manifest broken, wrong project props, or something like that) make R not generate, and then you won't have R.

But really, I've seen some examples of people doing point 3.

念﹏祤嫣 2024-11-16 15:20:50

我遇到了同样的问题,这是由于 R 的包与 Main 的包不一样。我刚刚将 Main 移至与 R 相同的包,点击“构建”后一切正常。

I had the same problem and it was due to the package of R not being the same as the one for Main. I just moved Main to the same package as R and everything is fine after I hit Build.

爱情眠于流年 2024-11-16 15:20:50

就我而言,adb 丢失了。安装 adb 后,一切正常。

In my case adb was missing.After installing adb everything worked fine.

花开雨落又逢春i 2024-11-16 15:20:50

您只需右键单击该项目并从上下文菜单中选择构建

(这对我有用。我正在使用 NetBeans 8.1)

You can just right-click the project and choose build from the context menu.

(This works for me. I am using NetBeans 8.1)

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