4

I am getting following Lint warning:

Inconsistent number of arguments in formatting string 'mystring'; found both 0 and 2

on following android string:

<string name="mystring">blablabla because %1$s.\n\nDo you want to delete this item? \n\n%2$s</string>

Does this make sense for you? I'm not understanding why and why 0 and 2 and not 1 and 2?

1
  • 1
    Does your code have multiple strings.xml file for translations? Please check all the translations of "sp_call_quarantine_item_format" string. In some translation of this string, there are zero number of argument. Commented Mar 28, 2017 at 8:45

2 Answers 2

1

This type of warning normally happens when format strings used, have different number of arguments defined across translations. when a language is not translated or updated correctly.

Please check for number of arguments in all the translations of "sp_call_quarantine_item_format" string. In some translation of this string, there are zero number of argument.

Sign up to request clarification or add additional context in comments.

3 Comments

I checked and in each translations there is the same 1 and 2, no 0 whatsoever
The problem is not with %1 or %2. It is with the count of the arguments you are using in the string. All of your translation strings.xml should have "sp_call_quarantine_item_format" string and all should have total 2 formatting arguments(%s variables).
Hmm, strange, because all my strings have the same amount of arguments.
0

In my case it was simply incorrect character for Japanese translation. Somehow Lint didn't like %d, but accept %d. Not sure if it's correctly shown here on SO.

enter image description here

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.