在上载到Google Play商店之前,可以进行语言更改,但在上载到Play商店后,无法进行语言更改。为什么?

Par*_*tia 4 android localization google-play

  • 在我的应用程序中,有两种语言。
  • 如果我从默认语言为英语的设备上下载应用程序,则不会更改为中文strings.xml(zh)。
  • 如果我将设备语言更改为中文并下载该应用程序,则它可以正常工作并且可以同时使用两种语言。也许是因为默认的strings.xml文件中包含英语。

可能是因为Google Play商店不允许用户下载它认为用户不需要的资源文件。

谁能帮我?谢谢。

Vru*_*tel 11

问题是您正在使用.aab文件在Play商店上发布应用。安装时会根据用户的电话设置删除本地化文件。

要解决此问题,您需要将此行放入build.gradle文件中,然后再次尝试上传

android {

  //... removed for brevity
  bundle {

     language {
       enableSplit = false
     }
   }
}
Run Code Online (Sandbox Code Playgroud)

链接参考


bla*_*ade 6

正如@Vrushi Patel 所说,这与 Android App Bundles 相关。要解决此问题,您必须编辑基本模块的build.gradle 中android.bundle块,如下所示,如官方文档中所述

android {
// When building Android App Bundles, the splits block is ignored.
splits {...}

// Instead, use the bundle block to control which types of configuration APKs
// you want your app bundle to support.
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
    }
    density {
        // This property is set to true by default.
        enableSplit = true
    }
    abi {
        // This property is set to true by default.
        enableSplit = true
    }
}
}
Run Code Online (Sandbox Code Playgroud)