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.

10 comments:

Dane Larkin 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 Abdullah said...

I did this but it cannot solve this

Allan Quirós said...

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

Allan Quirós said...

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

RAMYA SYL said...

Thanks a lot. This really helped me. :)

Emre İŞBARALI said...

Thanks that worked for me.

ASHOK KUMAR K R 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!

Related Posts with Thumbnails