Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Per-app languages don't work in release builds #408

Open
DimitarStoyanoff opened this issue Dec 9, 2022 · 2 comments
Open

Per-app languages don't work in release builds #408

DimitarStoyanoff opened this issue Dec 9, 2022 · 2 comments
Assignees

Comments

@DimitarStoyanoff
Copy link

Reproduction steps:

  1. Open either compose_app or views_app examples from PerAppLanguages folder in Android Studio.
  2. Create a keystore and build release app bundle.
  3. Use bundletool to run the app on a device.

Expected result:
Text language changes upon selection.

Actual result:
App stays in the default language, state change is not triggered. Killing the app and restarting it doesn't change the app strings language. The compose_app example even gets an ANR.
On SDK 33 in device settings the correct language is set for the app. AppLocalesStorageHelper logs show the selected locale was persisted correctly, but the app does not reflect those changes.

Tested on Pixel 6 emulators with SDK 31 and 33, as well as on physical OnePlus Nord.
Tested with AGP versions 7.2.2, 7.3.1 and 8.0.0-alpha09.

@ashnohe
Copy link
Contributor

ashnohe commented Dec 16, 2022

Thanks for flagging this issue @DimitarStoyanoff! I can replicate. This look to be an issue with split apks.

As a workaround you might disable language splits, see Handling language changes. The below works as a workaround:

bundle {
  language {
    enableSplit = false
  }
}

Another option may be to use the Play Core library to download languages on demand, see Download additional language resources or this blog post. I've not yet tested this.

The last option is to use --mode=universal instead of --connected-device as a bundletool parameter to create a single apk instead of a split apk. That will not work in production however, as user's will run into the same issue with languages not downloading on request.

More info:
The language is I believe not switching to one of the other languages because the language is not set as a system language preference and therefore not included in the initial split apk. For example, if I set my system language preferences to English and Japanese, the compose in-app language picker (on a release build with a split apk) works for those two languages, but not for the other languages.

I'm connecting with the team internally on this and will circle back, but hopefully the above workarounds unblock you in the meantime.

@ashnohe ashnohe self-assigned this Dec 16, 2022
@DimitarStoyanoff
Copy link
Author

Thank you @ashnohe for the analysis and for the workarounds! I will proceed with alpha testing and using them for the time being.

I had also opened an issue in Issue Tracker for this case (though it got some spam comments for whatever reason). Will post a link to this update there.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants
@DimitarStoyanoff @ashnohe and others