Format string XXX is not a valid format string so it should not be passed to String.format

Issue

I have android app and this string in resources:

<string name="create_group_select_people">Select up to %1$d people!</string>

This is called from fragment:

Integer countMax = 5; //also tried just "int" - nothing changed
getResources().getString(R.string.create_group_select_people, countMax);

but I got error:

Format string 'create_group_select_people' is not a valid format string so it should not be passed to String.format

I can’t understand what is wrong? When I launch app – it shows me literally “Select up to %1$d people!”

Solution

I just copied the code and it works well.
so you may need to check some other place,Here are my suggestions.

  1. clean project
  2. check multi-language files
  3. or just use String.format just like others said

Answered By – ohdroid

This Answer collected from stackoverflow, is licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0

Leave a Reply

(*) Required, Your email will not be published