R cannot be resolved to a variable in a new project

Possible duplicate:
R cannot be resolved - Android error

I can’t create a new project for Android, either on Windows or on Ubuntu! I have versions 2.3.3 and 2.2 and 4.0 of android sdk and I want to create a new project using version 2.3.3. But after creating the project, he says that R cannot be resolved by a variable .

I read all the questions related to this topic, and I made all the proposed solutions, but none of them worked for me. ("Clean project", check the Android version in the "Build Path" menu, check the xml files, lowercase xml file names, etc.)

Since I use an empty project, this is not due to incorrect xml files or some errors in java codes (since God makes his empty project !! how can it be broken?)

I do not know what to do. We appreciate any suggestions.

+6
source share
3 answers

If cleaning up the project does not work and if there is no problem with xml files (since this is a new project). Then go to androidmanifest.xml , edit it and add spaces between the lines, save it. Now clean the project, the error will disappear.

This is due to an obsolete r.java file. When we edit the Android manifest file, R.java is created again.

+7
source

This is due to an error in the XML files, view all xml files and check the Problems window. and then clean the project.

Hope this works.

+1
source

I had exactly the same problem. Here is what worked for me:

  • change permissions of the SDK folder: (chmod -R 777)
  • add import android.R;
  • project-> Clean
  • remove import android.R;
+1
source

Source: https://habr.com/ru/post/921844/


All Articles