android - 应用程序中不显示多语言字符串

标签 android android-gradle-plugin

  • 我在 gradle 中有这个设置
  • 我已上传 .aab playstore。
  • 该应用支持多种语言,即英语马来语

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 = true
        }
        density {
            // This property is set to true by default.
            enableSplit = true
        }
        abi {
            // This property is set to true by default.
            enableSplit = true
        }
    }
}

问题:当我从 Play 商店下载应用程序后,我只能在应用程序中看到 English 字符串,而当我下载时,Bahasa 语言不会出现切换语言

问题:指定language-split = true是否会导致此问题

最佳答案

您所做的一切都很好,似乎当您的设备不包含您从应用程序中选择的指定语言时(即应用程序中的语言设置)Play核心库 strong> 无法为您获取该资源,因为您的设备不支持该区域设置。

因此,解决方案是手动请求它为您下载该资源。

您可以通过向 SplitsInstallManager 发出请求来做到这一点。

创建新的 SplitsInstallRequest 并将其提供给 SplitsInstallManager,以便它为您提供该资源。

查看下面的代码 fragment :

// Creates a request to download and install additional language resources.
val request = SplitInstallRequest.newBuilder()
    // Uses the addLanguage() method to include French language resources in the request.
    // Note that country codes are ignored. That is, if your app
    // includes resources for “fr-FR” and “fr-CA”, resources for both
    // country codes are downloaded when requesting resources for "fr".
    .addLanguage(Locale.forLanguageTag("your language code here"))
    .build()

// Submits the request to install the additional language resources.
splitInstallManager.startInstall(request)

<强> Refer here 了解更多详细信息。

关于android - 应用程序中不显示多语言字符串,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57781961/

相关文章:

android - 尽管使用相同版本,所有com.android.support库都必须使用完全相同的版本规范

android - 无法在 android gradle 插件 4.1.0 中获取未知属性 'apkNames'

android - 列表 Activity 中的上下文菜单

android - 执行 org.jetbrains.kotlin.gradle.internal.KaptWithoutKotlincTask$KaptExecutionWorkAction?java.lang.reflect.Invocation? 时发生故障?

java - 安卓工作室 : UNEXPECTED TOP-LEVEL EXCEPTION:

android - 使用 javadocs 将库项目编译为带有 gradle 的 jar

android - 不同设备的 Admob 横幅尺寸

android - MutableLiveData 的 postValue 方法返回 null

android - 在 Gradle 4.1 中为特定的 flavor-buildType 组合设置 applicationIdSuffix

android - Gradle 同步失败 : Could not find com. android.tools.build :gradle-experimental:3. 3.2