60

After adding new items in strings.xml, quite often they don't start working immediately in Android Studio's Preview.

Couldn't resolve resource @string/faq_customer_service

Preview looks like this:

enter image description here

I've obviously tried to re-build the project, and even run gradle clean assembleDebug, but it doesn't seem to help. On emulator & real device the newly-added string resources do work.

Any trick to force Android Studio to reload the resources so that the correct texts show up in Preview?

MPelletier
  • 16,256
  • 15
  • 86
  • 137
Jonik
  • 80,077
  • 70
  • 264
  • 372

6 Answers6

170

The only reliable way I've found so far is reloading the project / restarting Android Studio.

Quickest way to do that is File → Invalidate caches / Restart... → Just Restart.

Feel free to post better solutions!

Jonik
  • 80,077
  • 70
  • 264
  • 372
12

you DO NOT need to close the entire project. It's just way too much for so little problem.

Just refresh the preview (click the "refresh" button) refresh button arrow

provided from https://stackoverflow.com/a/34754707/3339597

Community
  • 1
  • 1
Re'em
  • 1,869
  • 1
  • 22
  • 28
  • and if it doesn't work, try building the project (Ctrl+F9) and then pressing the refresh button. – Re'em Jul 10 '16 at 14:40
  • Thanx! It's helped me when I trying to use vector graphic! +1 – Trancer Jan 31 '17 at 16:56
  • This button was removed in Android Studio 2.3. And now the only choice is to reload the whole IDE... anybody knows how to bring the button back? Amazing when companies just think refresh is not necessary. – TatiOverflow Jul 13 '17 at 17:54
6

Right click on project and Synchronize '...Project' worked for me.

Şah-ı Merdan
  • 494
  • 7
  • 15
  • Cool, thanks. Although now, with Android Studio 0.3.1, the problem seems to be fixed; Preview immediately shows the changes in `strings.xml`, even without Synchronize. – Jonik Nov 01 '13 at 05:04
  • 4
    Actually, now that I was running into Preview problems again, Synchronize did nothing for me, but Restart helped. – Jonik Nov 18 '13 at 10:59
  • After synchronizing do not forget to refresh the preview! – user2520215 Jun 14 '16 at 08:35
0

There are three steps for solving this problem

  1. Build -->Clean Project

  2. Build -->Rebuild Project

  3. Restart android studio

Harun ERGUL
  • 5,770
  • 5
  • 53
  • 62
0

Couldn't resolve resource @string/faq_customer_service or Couldn't resolve resource @id/visible or Couldn't resolve resource @id/masked The solution is if you implement TextInputLayout the above problems may arise ... so Simply add those id or strings to xml files as their property.

0

Render Problem:

Couldn't resolve resource @string/hello_blank_fragment

Just refresh the Layout.

work for me..

Zain
  • 37,492
  • 7
  • 60
  • 84
HeshanHH
  • 653
  • 7
  • 9