151

Here is my values\strings.xml (the default file) and everything is self explanatory: enter image description here

My question(s):

  1. How can it be "not found in default locale" if I am editing the default locale (values\strings.xml)?
  2. How can it be a lint translation error if I set translatable="false"? In the values-pl\strings.xml (and values-ru, values-iw folders as well) the strings don't exist even? it shouldn't anyway.
  3. I can't seem to understand why I don't get the error for the Russian string.

(I would show the values-ru\string.xml or values-pl\string.xml here but there is nothing there of interest, since the strings are missing anyway...)

PIXP
  • 2,382
  • 3
  • 19
  • 28
  • 4
    If this is something that happens every now and then, just perform the usual cleans (clean/rebuild or invalidate caches/ restart on ASTUDIO, etc.) Unless, of course, the error is “real”. ;) My point is, with Android Studio 3.2 (beta atm), it happens kinda randomly, good strings are underlined, you touch something and the error disappears. It’s buggy. ¯\_(ツ)_/¯ – Martin Marconcini Sep 05 '18 at 21:22
  • 1
    Try this method: https://stackoverflow.com/a/53780805/7831470 – Sagar Giri Jan 04 '19 at 05:15
  • Running Android Studio 3.3.2 at the moment. This happens to me occasionally if I duplicate a string name in the strings.xml file (such as when copy-pasting). It's kind of frustrating but cleaning and restarting seems to fix it. – John Riggs Apr 11 '19 at 22:26
  • 1
    It happens very frequently if you move a resource from one file to another file in another module. I have to invalidate cache every time, clean-up/build have no effect. Seems an issue with indexing. – 3c71 Jun 01 '19 at 11:48
  • Running the app worked for me – k4dima Jul 22 '20 at 14:04
  • It just happened to me too. Seems to be an IDE problem as the app builds and runs fine and displays the affected message. The message isn't duplicated anywhere. – ka3ak Oct 10 '20 at 05:47

18 Answers18

133

this happened to me too

I do 2 things:

  • Verify entire file to see another translate not done ( I have ones in file en but in pt-br)
  • Clean, update gradle and quit and restart the Android Studio
JoaoLopesF
  • 1,462
  • 1
  • 10
  • 7
  • 11
    Just clean the project and restarted Android Studio. And it worked ;) – Ektos974 Nov 23 '18 at 09:37
  • 27
    In case cleaning the project and restarting Android Studio does not work, please try to run Invalidate Caches / Restart. – makunomark Nov 27 '18 at 08:20
  • 3
    Cleaned and Invalidate Caches / Restart. Worked for me too! :) – MrObjectOriented Jun 19 '19 at 06:55
  • 3
    ❗ Try removing the line and re-adding it before you do this. Life is short. – Nolan Amy Sep 07 '19 at 03:16
  • I think u should add a supplement to the answer, namely the command: `Invalidate Caches / Restart`. In order not to search in the comments, as I did for example. – Morozov Sep 09 '19 at 06:55
  • Given the frequency at which it happens, I'd rather use lekanbaruwa solutions that have already worked 3 times today: simply restart Android Studio. – 3c71 Apr 15 '20 at 09:03
  • Andriod Studio is one of the worst programs I have ever used and with each update, it is getting worse. – beginner Apr 22 '22 at 07:35
94

Rebuilding can take a long time. YMMV, but...

Simply remove the offending line and re-add it.

Worked for me. Very fast.

Nolan Amy
  • 10,785
  • 5
  • 34
  • 45
25

In my case this helped me:

  1. Select the strings that cause 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.

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

Press Invalidate Caches / Restart ... to restart android studio. It worked for me. Actually this happened when I had copied files from my other computer and pasted via file explorer.

abir-cse
  • 507
  • 3
  • 12
10

I solved this issue by following below steps:

  1. cleaning my project

  2. rebuilding it

  3. and finally pressing invalid caches/ Restart in file menu

halfer
  • 19,824
  • 17
  • 99
  • 186
8

If you just Clean Project it probably works. It worked for me.

StackOverflower
  • 369
  • 2
  • 12
6

Quitting Android Studio and restarting it fixed it for me.

lekanbaruwa
  • 167
  • 1
  • 4
  • It works for me too, it's much less painful than invalidating cache and restarting. – 3c71 Apr 15 '20 at 09:02
5

I had the same error message, just with the weird issue that it was thrown in the default locale itself and all translations. Turns out you should not use dots in your name (e.g. name="bla.blub") because it will be internally converted to "bla_blub" and then it cannot match with "bla.blub", hence the error. I only had to change the dots to underlines in the default locale and then all other errors in other translations (including dots in the name) were gone as well.

But be aware that other build tools can still create issues, so replace all the dots with underlines instead!

CitrusO2
  • 846
  • 10
  • 17
3

You simply just have to copy the offending line (or just one of the multiple of offending lines), remove it, and re-paste it. That removed the issue for me.

  • While this may help OP, it's better to add more details, explanation, examples, etc. Please [provide answers that don't require clarification from the asker.](https://meta.stackexchange.com/questions/214173/why-do-i-need-50-reputation-to-comment-what-can-i-do-instead) – Til May 10 '19 at 16:39
  • Don't know what else could be added for clarification. A bug in the tool - it's as simple as that. This answer is no less detailed than any of the other good answers here. It is however a duplicate of an earlier answer. –  May 26 '21 at 07:00
2

Just make sure that you have same naming conventions on all strings files including the same capitalization. let's say if you have "sign_in" in strings.xml and "sign_In" in your fr/string.xml, so it will give you error on fr/strings.xml like "is translated here but not found in default locale". So, when you edit to "sign_in". The error will remove.

2

I was having this problem for all the strings in my xml file.

The thing is, your default strings.xml shouldn't have a tools:locale attribute as the other translated files have. If it does, whenever I compile the app in release mode, it treats it as another translated file.

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

I've created a tool to manage the translation status of android apps. It not only tells you what strings are missing on the other languages, but it can also report, and clean the left over strings that you may have deleted on your default translation file.

https://github.com/gubatron/android-missing-strings

To clean all left overs in other languages invoke like this

./ams --cleanleftovers -o all.txt

This will clean the left over strings and it will output the missing strings report for all the languages into the all.txt file

Gubatron
  • 6,222
  • 5
  • 35
  • 37
0

Copy and paste didn't work for me.

I also tried Clean and restart, the previous error was gone but new entered strings still have new errors occur.

I tried closing the opened strings.xml file and Translations Editor, then restart.

strings.xml file and Translations Editor

That works for me.

Roy Wan
  • 31
  • 3
0

Well, in my case, this happened when there was a format error with the previous string of the string that's being reported. Unfortuantely that format error was not reported. Correcting the format error solves the issue.

LXJ
  • 1,180
  • 6
  • 18
0

Add this,It will work

   <resources xmlns:tools="http://schemas.android.com/tools" tools:ignore="ExtraTranslation">
UJJAWAL KUMAR
  • 31
  • 1
  • 6
0

Just go to the Build menu and select clean project.

Aaron Dancygier
  • 1,996
  • 19
  • 20
0

Everything else suggested above failed for me, what worked was to use the File -> Repair IDE Android Studio menu option. Select to restart the IDE after the repair completes and prompts you.

Ugo
  • 587
  • 8
  • 12
-1

Press double shift for open Translations Error and then check and uncheck in Untranslatable column the item with error.

Braian Coronel
  • 22,105
  • 4
  • 57
  • 62