Monday, November 24, 2014

Fixing Android Studio cannot resolve symbol R errors after an SDK update

Recently I updated an installation of the Android Studio beta to the latest Android SDK version on a workstation. Subsequently after the upgrade, the Android source project in the Studio will show error messages as shown in the screenshot below and all the R symbols in the editor would be highlighted in red when a new activity is added to the project. The console would be complaining about numerous unresolved resources e.g. "No resource found that matches the givent name 'android:TextAppearance.Material.Body2'".


The solution is to change the project settings to build using the latest Android SDK, as described below.

  1. In the Android Studio IDE, select File | Project Structure.

    The Project Structure dialog box appears.

  2. If not selected, choose the Project app module.
  3. Under the Properties tab, in the Compile Sdk Version field, choose the latest SDK .e.g API 21: Android 5.0 (Lollipop).


  4. In the Build Tools Version field, choose the latest version, e.g. 21.1.1.
  5. Click OK.

    The project is refreshed and the error messages no longer appear.

11 comments:

Unknown said...

Thanks for this after reading a bunch of stack overflow questions changing the build tools version was what helped.Thank you.

Sai Prasad said...

This did not resolve the issue for me. It is indeed using lolipop, and build tools version 21.1.2. I am trying to create an app that uses openstreetmaps and import org.andnav.osm.R; is throwing up a bunch of errors. Please help!

Adil said...

I did this but it cannot solve this

Allan Quiros said...

Thanks a lot, I did haven't idea why Android studio showed this problem and Now is working.

Allan Quiros said...

Thanks a lot, I did haven't idea why Android studio showed this problem and Now is working.

Unknown said...

Thanks a lot. This really helped me. :)

Unknown said...

Thanks that worked for me.

ash said...

This worked awesome!! I will bookmark your site thanks...

ADMINISTRADOR said...

muchas gracias, me funciono a la perfeccion.

SMS-BOOK said...

Do: Build > Clean Project

IMPORTANT: Make sure you don't have any Errors after Clean Project in Message Pane (Alt+0). If you find any red circles with exclamation mark, than you must remove those errors in your code.

Mostly these errors are related to @string/ or @array/. Clean Project again and done!

Unknown said...

This worked for me after reading and trying all possible solutions on stackoverflow for the past 4 to 6 hours.

Thank you