0

I have searched many questions but cant seem to get solution to my problem. The issue came after i Updated using download manager while my eclipse was running.

The Problem: Whenever i do clean build , "R cannot be resolved to a variable" issue comes. R is not present in gen folder. If i comment all the places R is used, the R.java gets generated, I uncomment the code containing R.id.. and things run normally , only to come up again if clean build is triggered.

If I build normally, the changes are not getting reflected.

How issue came:

  1. Download manager - > Update.

  2. Intall 16 packages button - didnt do much, because some peer connection refused issue came.

  3. Delete 1 package option. I used this option twice and deleted 2 folders whise names I dont remember.

After this all projects had thousands of compilation errors. The tools folder was not present. Added that by unzipping it.

Now whenever i do clean build , "R cannot be resolved to a variable". R is not present in gen folder.

If i comment all the places R is used, the issue is gone, I uncomment the code and things run normally , only to come up again if clean build is triggered.

Solutions tried:

  1. No issue in any of XML's because it generates if R is not used

  2. Project -> Build project

  3. Build automatically
  4. Project -> Add support

It seems some tool is not running properly. Earlier, whenever I would do Project-> run as->, R would get generated. Now apk is not present error comes.

Update:: Project -> Run As -> Error "AndroidManifest.xml is missing" If I open manifest by double click, error comes:

parseSdkContent failed
Could not initialize class android.graphics.Typeface

parseSdkContent failed
java.lang.ExceptionInInitializerError

Have deleted the home/.android folder , still error is coming. The original R error is still coming.

Update2: 1. The issue android manifest error goes by clean build. 2. Then another error came, so I included ..\appcompat_v7 in android library 3. Now there were 2 android-suppport-v4.jar. So i manually deleted one of them. 4. Now my changes are not getting reflected on build. And on clean build, R issue comes.

user4057066
  • 295
  • 3
  • 14
  • try to open problem window it will assist you to solve your error. – Haresh Chhelana Dec 02 '14 at 05:39
  • Check your Layout file or resources. There is something wrong that's why R is not generated... – M D Dec 02 '14 at 05:44
  • Problem window only states "R cannot be resolved to a variable". Earlier - R used to be generated while doing Run As. During compilation, ID's newly added in XML's will always give error, while doing run they would be added to R. – user4057066 Dec 02 '14 at 06:03

5 Answers5

1

Happens to me all the time. Try doing Rebuild Project and Clean Project. This should work.

More solutions at "R cannot be resolved to a variable"?

Community
  • 1
  • 1
Gil Maimon
  • 153
  • 8
0

go project properties and select java build path select the android version checkbox. or remove and add the appcompat.

ATRS
  • 247
  • 4
  • 15
0

enter image description here

or you can use that.

First Right-click on your project thenn after Choose Properties chose android Choose Android in the left menu then after Tick a box next to the appropriate Project Build Target. then Click Apply and OK

you used vertion is not proper so it error comes in your project

if your project vertion is greaterthan the sdk then you want to update sdk

Dilavar Malek
  • 1,157
  • 11
  • 18
  • yes , after update Project build target is Android 5.0 and this is unchecked. If I check it close properties and again open, again it is unchecked. May be this is the issue. – user4057066 Dec 02 '14 at 06:59
  • if your project vertion is greaterthan the sdk then you want to update sdk -- how to check this? – user4057066 Dec 02 '14 at 07:00
  • in the above image we select build path. like that click on android which is above to android. and then you can see the vertion of your sdk – Dilavar Malek Dec 02 '14 at 08:09
  • Both have the same version:(. But the one in android is not getting saved. Means, I click the check box, save and then open it again through properties, again it is unchecked. – user4057066 Dec 02 '14 at 08:50
0

If you have updated your ADT,Some of the R.java files might not be generated. Navigate to settings ->SDK manager and check whether android SDK build tools are installed or not.If not install them and restart your IDE.Things should be working fine enter image description here

archon92
  • 447
  • 3
  • 13
0

Please check the recently worked xml(styles.xml, strings.xml, or any file with .xml) file, that contains any syntax error or mis spelling.

Prabhakaran
  • 379
  • 3
  • 7