How to fix this error "Error cannot resolve Symbol R" in Android Studio

Asked

Viewed 19,681 times

9

I imported a project made on Eclipse to the Android Studio and errors appeared in the code regarding the R with the following message

cannot resolve Symbol R

How to correct this error?

  • You usually get the option when you hover over to alt+enter

  • Try to give a clean in your project, also note if it was generated , if yes deletes it she will recreate.

  • I edited the title for something clearer. Always specify the problem in the title, this helps other people to find the question, remember your question CAN help other people.

  • in my case the problem was simple... and quite ridiculous, as they said above, the name of one of the images was different from what I downloaded from my git... fixed the file name and worked.

  • Make sure all your images are capitalized in the nomenclature, click Build, clean project and then rebuild project

6 answers

6


thus solved my problem

in the Android Studio was file and then in Project Structure

inserir a descrição da imagem aqui

Then go on app, in the field Properties in Compile Sdk Version and Build Tools Version select the latest version.

inserir a descrição da imagem aqui

Click OK and the error is gone.

5

That’s not the root of the problem.

The R is an automatically generated class, but only when the project has no error that can prevent it from being generated.

Go on Window -> Show view -> Problems and see what other mistakes are happening.

After troubleshooting these other errors, give the project a Clean so that the R is generated again.

4

I often came across this error, try to give "clean" and "rebuild" in the project. other options are:

"Tools" -> "Android" -> "Sync Project with Gradle Files"

If none of these solutions meet your error, get into the time-consuming process of checking your XML files and your Androidmanifest.

2

If the error persists even after following all of the above suggestions, do the following. Change the view mode from Android to Project soon you will see some unknown folders and at the root, (in mine is the first folder) will have one . Gradle, can exclude it and a clean in the design.

inserir a descrição da imagem aqui

2

That problem is something wrong inside the "res" folder, most of the time, the name of the images or anything else you have there are not according to the rules of the compiler, to do the test, cut out everything you have there and put it somewhere else and see if it solved the problem, if yes, look in all the items what is with some name not allowed, for example, starting with capital letter, with ifem or something like that.

0

Class, who could not solve by following the above options, follows the step that helped me to fix the problem.

Click Run > Edit Configurations.

inserir a descrição da imagem aqui

Then click on the option JAR Application and set the JRE and "Search sources ..." to the image, click Ok and then click Buil > Clean project and then Make Project. For me it worked properly....

inserir a descrição da imagem aqui

Browser other questions tagged

You are not signed in. Login or sign up in order to post.