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:

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

    ReplyDelete
  2. 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!

    ReplyDelete
  3. I did this but it cannot solve this

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

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

    ReplyDelete
  6. Thanks a lot. This really helped me. :)

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

    ReplyDelete
  8. muchas gracias, me funciono a la perfeccion.

    ReplyDelete
  9. 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!

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

    Thank you

    ReplyDelete