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
- 431
- 10
- 24
3 Answers
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.
- 3,127
- 1
- 22
- 29
-
@ super-qua, i imported project name.R "import com.simbotix.oovoo.R;" does nutting. http://www.evernote.com/shard/s283/sh/5928e229-4408-4893-a092-4e95c8470b8a/48aded3244b7fd61af0c3aea43eb93da – Shashi Shiva L Mar 18 '14 at 08:38
-
You have to use the package name defined in your `Manifest` with `package="..."`. From the screenshot it looks like that might be different – super-qua Mar 18 '14 at 08:46
-
Thanks @ super-qua but package name in my manifest is same package="com.simbotix.oovoo". – Shashi Shiva L Mar 18 '14 at 08:51
-
Did you clean the project again? Also, as @gauravgupta stated below, you layout might contain errors. – super-qua Mar 18 '14 at 08:53
-
I think some error in- R not generated in gen folder https://www.evernote.com/shard/s283/sh/0d0731e0-d0d7-4517-9116-bbe2922e647e/75e7af566cce3e4d91f310be99e2df2a – Shashi Shiva L Mar 18 '14 at 09:08
-
Yes, that's exactly what it looks like. You should try to fix the layout error. – super-qua Mar 18 '14 at 09:11
-
I had the same problem;clean the project; make android studio build gradle again; by restarting IDE ; if it didnt worked just Restart your system; it worked for me – Imran Sep 09 '19 at 15:21
Try to clean you project and build. it will work. Kindly remove import android.R; in your activity
- 2,815
- 4
- 18
- 29
-
@ Murali Ganesan, i deleted import android.R and clean and build the project. does nutting. – Shashi Shiva L Mar 18 '14 at 08:42
'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.
- 1
- 1
- 4,468
- 2
- 35
- 67