【Android】解决aab上传Google Play后下载语言文件缺失的问题

【Android】解决aab上传Google Play后下载语言文件缺失的问题,第1张

【Android】解决aab上传Google Play后下载语言文件缺失的问题

官网(https://developer.android.com/guide/app-bundle?hl=zh-cn)有对aab的描述:

Google Play 会使用您的 App Bundle 针对每种设备配置生成并提供经过优化的 APK,因此只会下载特定设备所需的代码和资源来运行您的应用。

有些手机只内置了中文、英文等几种,如果从Google Play下载应用,那么Google Play会剔除掉其他(它认为是多余的)语言资源文件,从而导致应用切换语言不成功。

解决方法:

gradle那里可以配置是否需要动态分发的内容。

android {
    ...
    // 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
            // 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
        }
    }
}

如上,language enableSplit = false代表aab不进行分包处理,Google Play下载apk后,语言资源文件是完整的。

更多 Android App Bundle的配置,可查看官网文档:

https://developer.android.com/guide/app-bundle/configure-base?hl=zh-cn

欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/zaji/5696850.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-12-17
下一篇 2022-12-17

发表评论

登录后才能评论

评论列表(0条)

保存