0

I know that it has been asked thousands of times, but I really can't fix this at this momment. I'm trying to update an old project(already submitet to the play store). The only dependency was the v7 appcompact lybrary and so I added it to the new workspace and updated the existing project dep[endencie, but I'm still getting the strange R cannot be resolved to a variable error.

Here is what I'm doing and even if I'm 99% sure that it is what I have to do, it's not working.

  1. Updating the project dependencie:

enter image description here

everything looks nice, but when I clean and rebuild the project, here is what happens:

enter image description here

and the problem is still there. I'm really going to start crying, because it was a working project, buta after switching to a new workspace and checking it out from my git repository, I can't get it working.

Do you have an idea what is going on? I know that I miss something small here, I know that it has been asked so many times, but I can't find an answer fitting on my case.

chility
  • 758
  • 1
  • 9
  • 22

2 Answers2

2

Remove library project android-support-v7-appcompact and add it again properly.

  • also check your package name in manifest file.

  • update SDK Build Tools on SDK Tools -> SDK Platform Tools, if not, please try it and clean & rebuild.

  • check imports to see any broken R.java imports. if there is "import android.R;" remove it.

  • check style and layout xmls to prevent any missing drawables or depreciates.

also see : R cannot be resolved - Android error

Community
  • 1
  • 1
Alper
  • 148
  • 1
  • 9
  • your screenshot shows it as error. Did you check it again? fixed now? – Alper Sep 06 '14 at 18:26
  • I'm adding it properly it seems ok and after the rebuild I'm getting the error shown on the screenshot. – chility Sep 06 '14 at 18:27
  • Remove that support library, and add like this way: Right Click on Project -> Android Tools -> Add Support Library... Did you recenlty update SDK Build Tools on SDK Tools -> SDK Platform Tools, if not, please try it and clean & rebuild – Alper Sep 06 '14 at 18:34
  • I tried everything and the R is still giving me errors. I think that I should move to IntelliJ, maybe it will be free of such crazy things... – chility Sep 06 '14 at 18:42
  • Ok I found what is wrong. I see that many things have changed in android the past 2 months... – chility Sep 06 '14 at 18:45
0

Just to tell my experience with this problem in a Java project with JDK8. In my case I was running the project in a Mac with Yosemite. Reading the specs. Android Studio and SDK, I've found that projects could be compiled up to Yosemite version.

I changed my environment variables to JDK7 and it worked!

PabloCocko
  • 110
  • 1
  • 8