I had a horrible bug in the Brainy Cell game. I used the String.format method without specifying the locale, despite all the warning spit out by Android Studio.
I actually have a good excuse why I missed this issue: I implemented the whole game in about one week. The thing is that I load the levels from the asset folder and all levels are named something like c01l01 (chapter 01 level 01). To obtain the level name I used the String.format method as follows:
return String.format("c%02dl%02d", chapter, level);
Even though this code looks harmless it is actually really bad. If you don’t specify a locale, for an non-latin locale this will result in something like: c٠٢l٠١. Obviously this is not a valid level file name so the game crashes. The fix is simple, specify the locale:
return String.format(Locale.US, "c%02dl%02d", chapter, level);
This way the method will always return the same level name, regardless of the user locale.