0

i cleaned my android project and now im getting this error saying i need to put import android.R; at the top, when i do that it then says that any field isnt visible, for example i have this line of coding

setContentView(R.layout.inbox);

when i hover over the error mark i get

Multiple markers at this line
    - Inbox cannot be resolved or is not a field
    - R cannot be resolved to a variable.

Im getting this on all of my Activity

UPDATE:

some errors from my XML that is causing the R.java to not be rebuilt durring the cleaning proces

Description Resource    Path    Location    Type
error: Error: No resource found that matches the given name (at 'drawable' with value '@drawable/friendrowbg'). friendslistselector.xml /atmebeta/res/layout    line 8  Android AAPT Problem
error: Error: No resource found that matches the given name (at 'background' with value '@drawable/friendslistselector').   friend_row.xml  /atmebeta/res/layout    line 1  Android AAPT Problem
error: Error: No resource found that matches the given name (at 'drawable' with value '@drawable/friendrowbg'). friendslistselector.xml /atmebeta/res/layout    line 2  Android AAPT Problem
error: Error: No resource found that matches the given name (at 'drawable' with value '@drawable/friendrowbg'). friendslistselector.xml /atmebeta/res/layout    line 6  Android AAPT Problem
error: Error: No resource found that matches the given name (at 'listSelector' with value '@drawable/friendslistselector'). friends.xml /atmebeta/res/layout    line 29 Android AAPT Problem
NodeDad
  • 1,519
  • 2
  • 19
  • 48
  • 1
    Check in your xml file for any errors, save the xml and try again. And dont use `android.R`. – Oam May 21 '13 at 19:17

4 Answers4

1

You should not import android.R. There is up to a couple minutes (~2) for R.java to be recreated at times.

If R.java is not created then there is a problem within your res folder. What helped the OP (found in the comments as well) was the @drawable reference is referencing items that are located within res/drawable/, not within res/layout. The layout folder is only for layout xml files, while the drawable is for your apps images.

TronicZomB
  • 8,667
  • 7
  • 35
  • 50
1

You may want to check a similar question posted before:

"R cannot be resolved to a variable"?

Basically, it seems that it could be an error on an XML or your code that prevents R to be generated again, hence, it's missing. In worst scenario some configuration on your project may be missing or a library project may be causing the issue.

Check that question or provide more information about your set up.

Community
  • 1
  • 1
fr4gus
  • 396
  • 7
  • 18
  • This kind of makes sense, i just added some list_row.xml files to build a custom ListView... – NodeDad May 21 '13 at 19:34
  • Check in the Window > Show View > Problems tab. Do you see more errors than just the R file ones? – Tim C May 21 '13 at 19:37
0

Your project itself will have an R file for your local resources (everything in the /res/ directory).

If your project is com.example.app... add this line

import com.example.app.R;
RyanInBinary
  • 1,533
  • 3
  • 19
  • 47
  • tried this and it just says that that import cant be resolved – NodeDad May 21 '13 at 19:22
  • which means that there were issues building your project. Check to make sure everything compiled correctly in eclipse. Once your R file gets generated this will work for you. – RyanInBinary May 21 '13 at 19:37
0

The R file is built automatically when the project is built. Do you have "Build Automatically" checked (it's under the Project menu)? If not, doing a Clean will remove the R file, but a Build will not be executed. You'll need to either select Build, or check the Build Automatically.

You can also go to Window > Show View > Progress and see if a build is in progress. Doing a Clean should trigger a build if Build Automatically is checked.

Tim C
  • 635
  • 5
  • 18
  • Build Automatically is checked, i did uncheck it earlier and clean to see if that would fix it and it didnt. – NodeDad May 21 '13 at 19:33
  • Did you try manually doing a build? Does the Progress window show the build process? – Tim C May 21 '13 at 19:35