4

I have a feature in my app where user can select various language at runtime from inside the app and it was working fine till I was deploying app on play store in APK format but it stopped working since i started deplyoing my app in App Bundle format. Default string resources are not being replaced with the one that user has selected but when I change whole device language from device's settings option, then my app gets updated with new configured resources from play store and everything works fine. Is there any way I can enforce all the strings resouces to pushed along with base apk or any other way I am unaware of? Please help. The code I am using to change language is -

        Locale locale = new Locale(langCode); //langCode is the code of the language user has selected
        Locale.setDefault(locale);

        Resources res = parentContext.getResources();
        Configuration config = res.getConfiguration();
        config.setLocale(locale); // = locale;
        res.updateConfiguration(config, parentContext.getResources().getDisplayMetrics());
Devansh Kumar
  • 1,552
  • 1
  • 15
  • 27

1 Answers1

9

Edit:

The PlayCore API now supports downloading the strings for another language on-demand: https://developer.android.com/guide/app-bundle/playcore#lang_resources

I found the solution here. Copying from there

For the time being, you can disable the splitting by language by adding the following configuration in your build.gradle

android {
    bundle {
        language {
            // Specifies that the app bundle should not support
            // configuration APKs for language resources. These
            // resources are instead packaged with each base and
            // dynamic feature APK.
            enableSplit = false
        }
    }
}
Devansh Kumar
  • 1,552
  • 1
  • 15
  • 27