1

I created new android project in eclipse and created MainActivity.java and activity_main.xml files but the activity_main.xml file is not recognizing. Project-> clean-> clean all project does nothing . I deleted import android.R does nutting. What should i do? see the screenshot. R not generated in gen folder

enter image description here

3 Answers 3

4

Generally in android there are two different R files you can acces:

  • The android.R - provided by the android platform
  • Your projects R - holding your resources

You have to import your R file, not the android.R, in order to access your layout. This is done using your package name on import like this:

import your.package.name.R;

The android.R is used for resources provided by the android platform, while your R file contains the resource you added to the project.

Sign up to request clarification or add additional context in comments.

7 Comments

@ super-qua, i imported project name.R "import com.simbotix.oovoo.R;" does nutting. evernote.com/shard/s283/sh/5928e229-4408-4893-a092-4e95c8470b8a/…
You have to use the package name defined in your Manifest with package="...". From the screenshot it looks like that might be different
Thanks @ super-qua but package name in my manifest is same package="com.simbotix.oovoo".
Did you clean the project again? Also, as @gauravgupta stated below, you layout might contain errors.
I think some error in- R not generated in gen folder evernote.com/shard/s283/sh/0d0731e0-d0d7-4517-9116-bbe2922e647e/…
|
0

Try to clean you project and build. it will work. Kindly remove import android.R; in your activity

1 Comment

@ Murali Ganesan, i deleted import android.R and clean and build the project. does nutting.
0

'R.layout' is not able to find your layout that means 'R' is not pointing to your application resources. It possibly is pointing to android's resources because this R is of android sub-system.

Look at the import statement, R probably will be of android.R. So you need to tell that you need your R file to use your resources. So you need to import yourpkg.R.

If your layout contains some error then your R would be created in build process. So if your R is not getting created. Check your layouts and fix the issue in layout files.

This post may help in getting to know about Why R file is not generated.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.