6

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!

r43r31
  • 61
  • 1
  • 1
  • 3

8 Answers8

11

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

  • "Me too!" I did an `ctrl-shft-I` and it added an `import anddroid.R` line. Had to remove that but just building worked. Thanks! – markspace Dec 24 '15 at 04:17
2

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

cablefan
  • 61
  • 5
1

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

Zuenonentu
  • 302
  • 1
  • 3
  • 16
0

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

Shubham
  • 2,753
  • 3
  • 27
  • 44
0

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

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

trincot
  • 211,288
  • 25
  • 175
  • 211
Taj Masindi
  • 136
  • 2
  • 10
0

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

Radim
  • 4,571
  • 1
  • 19
  • 25
  • I've got the SDK location set up, and the project has a build target. Anything else I'm missing? – r43r31 May 27 '11 at 13:27
  • I also have this issue. On creating a new project without coding. – Rex Whitten Jun 02 '11 at 14:39
  • further, I can reproduce this in Eclipse with Android 1.9, Android 2.2, and Android 3.0,3.1. I suspect an update issue with SDK Manager? I cant think all of these IDE's got corrupted templates all at once? – Rex Whitten Jun 02 '11 at 14:45
0

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.

Nanne
  • 61,952
  • 16
  • 112
  • 157
0

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.

toto2
  • 5,216
  • 19
  • 24