58

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?

4

7 回答 7

165

到目前为止,我发现的唯一可靠方法是重新加载项目/重新启动 Android Studio。

最快的方法是File → Invalidate caches / Restart... → Just Restart

随时发布更好的解决方案!

于 2013-10-17T16:47:59.777 回答
12

您不需要关闭整个项目。对于这么小的问题,这太过分了。

只需刷新预览(单击“刷新”按钮) 刷新按钮箭头

https://stackoverflow.com/a/34754707/3339597提供

于 2016-07-10T14:39:09.073 回答
6

右键单击项目并同步“...项目”对我有用。

于 2013-10-31T21:25:33.547 回答
0

渲染问题

Couldn't resolve resource @string/hello_blank_fragment

只需刷新布局。

为我工作..

于 2019-09-21T12:23:19.300 回答
0

解决这个问题的三个步骤

  1. 构建 --> 清理项目

  2. 构建 --> 重建项目

  3. 重启安卓工作室

于 2016-05-20T06:39:40.393 回答
0

文件→无效缓存/重新启动...→只是重新启动...对我不起作用

File → Invalidate caches / Restart... → Invalidate And Restart ... 为我工作

于 2018-08-29T23:16:35.540 回答
0

无法解析资源@string/faq_customer_service 或无法解析资源@id/visible 或无法解析资源@id/masked 解决方案是如果您实现TextInputLayout 可能会出现上述问题......所以只需添加这些id 或字符串到 xml 文件作为它们的属性。

于 2017-02-06T10:41:26.380 回答