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:
The R.java 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 R.java 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 R.java 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
Firstly ensure that you have defined the dependency of the support library v7 within your build.grade
, block dependencies
:
dependencies {
...
...
compile 'com.android.support:appcompat-v7:25.3.1'
...
...
}
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 R.java
, 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(R.id.<especifica el id de la vista>);