My app crashes in debug mode (not in release) when the device language is set to "English". A string resource can't be found, the error message is as follows:
android.content.res.Resources$NotFoundException: String resource ID #0x7f0c005a
When removing the part of the code that raises this issue, the app does not crash immediately, but another string resource is displayed as follows:
%1$s won't work unless you enable Google Play Services
I have the following resource files:
app/src/main/res/values/colors.xml
app/src/main/res/values/themes.xml
app/src/main/res/values/strings.xml
app/src/main/res/values-de/strings.xml
app/src/debug/res/values/ads.xml
app/src/release/res/values/ads.xml
When providing a separate language resource file in app/src/main/res/values-en/strings.xml, then it runs with the language set to "English", but it still crashes for other system languages.
- How can I use the string values from "main" while being in debug mode in a language that is not explicitly supported by my app?
- As a workaround I could duplicate the resource files that contain english translations, but then I would need to keep both sets of files updated for release (
values-en/*.xmlfor devices set to "english" andvalues/*.xmlfor devices set to an unsupported language). Is there a way to solve this without having to separately maintain all files that are translated into the same language as provided in the default values? - What's a better way for saving build-variant specific strings?
Do you have a base strings.xml file in the values directory (not the values-language)? If not, you should. It can be in any language (english is most common for a variety of reasons, but it doesn't need to be), but without a base values/strings.xml it doesn't know what strings to use for any locale without a match. When it doesn't have a matching locale it falls back to values/strings.xml