1

It's my 3rd day in Android dev. Just now my app. was working fine but instatntly all refrences to my R file started showing error. It was working fine couple of mins back.

Even the code like below , generated by ADK was working fine and now it shows the error

Code Snipppet:

@Override
        public CharSequence getPageTitle(int position) {
            Locale l = Locale.getDefault();
            switch (position) {
            case 0:
                return getString(R.string.title_Venue).toUpperCase(l);
            case 1:
                return getString(R.string.title_Teams).toUpperCase(l);
            case 2:
                return    getString(R.string.title_WeatherConditions).toUpperCase(l);
            }
            return null;
        }

Tried cleaning and rebuilding the soluition , no luck.

Kindly help.

Lalit

Lalit_vicky
  • 275
  • 1
  • 4
  • 15
  • can you post your `...android.R` import here please? – Lia Pronina Aug 28 '13 at 08:15
  • Try to remove the errors in your layout files if there are existing and try to clean project (in Eclipse : Project -> Clean), your R file will be regenerated. Don't forget to check the import (android.R != yourpackage.R) – Sw4Tish Aug 28 '13 at 08:17
  • Make sure you don't have errors in any of your resources XML files or your AndroidManifest.xml file. If an error is present in any of these, the project will not build and the R file will not be generated. – Aleks G Aug 28 '13 at 08:17
  • Check if you have any errors in your resource files. If you have any R.java won'r be generated. Check if you have imported android.R if so remove it. You should have reference to your R.java in your which is in gen folder – Raghunandan Aug 28 '13 at 08:17
  • My manifest and layout files are ok.. i have a namespace import android.R; thats generated default by the ADK. is thats the cause? – Lalit_vicky Aug 28 '13 at 08:25
  • The link is what i followed and solved the issue... http://stackoverflow.com/questions/15309941/import-android-r-in-eclipse-why ..just by deleting the import android.R; .. it really sucks to the beginner for such tasks by ecllipse.. BTW thanks guys for your quick responses. – Lalit_vicky Aug 28 '13 at 08:33
  • clean & rebuild your project ! – Rachit Mishra Aug 28 '13 at 08:36

2 Answers2

2

import should look like this:

import your.package.name.R;

and check xml files for errors please

Lia Pronina
  • 756
  • 3
  • 7
0

Here's how I fixed this in Eclipse:

Create R.java in gen folder manually and save. After that go to Project and click "Clean" The following message will display and your file will automatically be rewritten:

R.java was modified manually! Reverting to generated version!

This is alternate approach

R is an automatically generated class that holds the constants used to identify your >resources. If you don't have an R.java file (it would be gen/com.techfuze.app_name/R.java in >Eclipse with the 1.5 SDK) I would recommend closing and reopening your project or going to >Project > Build all (and selecting "Build Automatically" while there as recommended by >Josef). If that doesn't work than try making a new project, if the problem is recreated than >post here again and we'll go into more detail.

but I've found out that there was another problem that was causing the first one. The tools in the SDK directory didn't have the permissions to be executed, so it was like the didn't exist for Eclipse, thus it didn't build the R.java file.

So modifying the permission and selecting "Build Automatically" solved the problem.

onkar
  • 4,397
  • 10
  • 47
  • 85