Search code examples
javaandroidcharacter-encodingstring-formattingright-to-left

Fatal Exception: java.util.UnknownFormatConversionException Conversion: מ


This code gives error on String.format(...):

inviterNameTitleView.setText(
                String.format(
                        context.getString(R.string.sharing_invite_title),
                        inviter.getNameForTitle()
                )
        );

R.string.sharing_invite_title is <string name="sharing_invite_title">%s invites you to smth.</string>

What could be the reason of this error? The symbol that results in error is a right-to-left alphabet letter. Googling doesn't give any answers.


Solution

  • It turned out that the app crashed only when on Hebrew locale, which was with iw code (not on he), which was weird to have the old code on Android 5.0. The corresponding string in strings file had s% instead of %s. That gave the UnknownFormatConversionException.

    This happens because of lack of RTL support in Android Studio. See more detailed answer in this question: Android strings.xml resource - arabic language and dynamic formatted strings