error with


Folders error and in the mainActivity also error. it indicates a class (R.) which does not allow me to access the id of an xml Then the errors:

asked by Danserver 03.08.2017 в 05:34

2 answers


Explanation file

The file is automatically generated by the compiler. It is a class full of static variables in which each type of resource is identified.

All these XML structures of the resources will be read when the application starts, but when we find on a mobile platform the work with direct XML could be demolishing and slow. Therefore Android after reading the XML file loads all the structures that have been requested in memory and keeps the R file as a direct reference to the resources that have been loaded in this way the access will be direct and simple for the programmer.

The file will have the following structure that is shown in the image, in which you can differentiate the different types of resources, such as: attr, dimension, drawable, layout, etc. .

More information about the R file


The problem of not being able to generate the class or that an error appears with that class is generally due to an error in the resources, in which you can not create the reference of the resource id in that class or it may also be the case that you only need to clean the project, so I would advise you to do the following steps

Perform a cleanup of your project with:

Build > Clean Project

and then build it again with:

Build > Rebuild Project
answered by 03.08.2017 в 08:47

Firstly ensure that you have defined the dependency of the support library v7 within your build.grade , block dependencies :

dependencies {
    compile ''

If it is defined but it indicates that it is not installed you can click on the messages that indicate installing.

As for the file , I suggest you review any possible problem in the resources, it is important to point out that sometimes these problems are not shown so I suggest you clean your project by Build > Clean Project

This is a question related to this problem:

Android, "R's" red in the whole code

As an extra you have a detail that will cause a problem, if you use the findViewById() method,

ediNombre=(EditText) findViewById();

You must specify the id of the element in the layout that you load, in this case the one loaded with setContentView() that is activity_main.xml :

ediNombre=(EditText) findViewById(<especifica el id de la vista>);
answered by 03.08.2017 в 21:09