6

I am declaring a string in the strings.xml and I am getting this error

here is my code:

<string name="date_picker_title">Hire Date</string>
<string name="new_employee">New Employee</string>
<string name="show_subtitle">Show Subtitle</string>
<string name="hide_subtitle">Hide Subtitle</string>
<string name="subtitle_format">%1$s crimes</string>
<string name="choose_menu">Choose a Menu Option</string>

enter image description here

Gourav
  • 2,746
  • 5
  • 28
  • 45
ZIA ANSARI
  • 131
  • 1
  • 11

4 Answers4

15

Here in my case this just helped me:

  1. Select the strings that are causing error.
  2. Cut them.
  3. Paste them again!

If it doesn't work for you, try adding the same strings to strings.xml(v21) file.
This worked perfectly for me.

Gourav
  • 2,746
  • 5
  • 28
  • 45
10

Try this. It solved the error in my case.

Go to File -> Invalidate caches and restart . In Android Studio Menu Bar

Gourav
  • 2,746
  • 5
  • 28
  • 45
ArpitA
  • 721
  • 7
  • 17
  • 2021 but it's still here... *File -> Invalidate Caches / Restart ->* **Just restart** also works fine and faster than **Invalidate and Restart**. – Daniil Pavlenko Jul 23 '21 at 11:37
0

Besides all the answers here, make sure your default strings.xml doesn't have a tools:locale attribute. Apparently, the default locale is assumed to be English always.

Dielson Sales
  • 1,715
  • 1
  • 20
  • 25
0

Build -> Clean Project, after that Build -> Rebuild Project is work for me.

Htue Ko
  • 119
  • 2
  • 7