应用程序未出现在每应用程序语言设置中

Tim*_*241 6 android android-13

我目前正在尝试为我的应用程序支持每种应用程序语言。我按照说明操作

  • 我创建locales_config.xml
<?xml version="1.0" encoding="utf-8"?>
<locale_config xmlns:android="http://schemas.android.com/apk/res/android">
    <locale android:name="en-US"/>
    <locale android:name="fr"/>
</locale_config> 
Run Code Online (Sandbox Code Playgroud)

我添加了AndroidManifest.xml

android:localeConfig="@xml/locales_config"
Run Code Online (Sandbox Code Playgroud)
  • 在 中app/build.gradle,我添加了:
android {
    ...
    defaultConfig {
        ...
        resConfigs "en_US", "fr"
    }
}
Run Code Online (Sandbox Code Playgroud)

我的问题是我的应用程序没有出现在每应用程序语言设置中
我在模拟器和运行稳定 Android 13 的手机上进行了测试。

附加信息:

com.android.tools.build:gradle:7.2.2
compileSdkVersion 33
Run Code Online (Sandbox Code Playgroud)

如果有人成功了,我想知道我是否还缺少任何其他附加步骤。

编辑:将和替换
为 时它也不起作用。en-USen_USen

Tro*_*ton 3

中的根元素locales_config.xml必须是<locale-config>,但在您的 xml 中我看到<locale_config>(下划线应该是连字符)。

将您的文本更新locales_config.xml为以下文本,它将起作用:

<?xml version="1.0" encoding="utf-8"?>
<locale-config xmlns:android="http://schemas.android.com/apk/res/android">
    <locale android:name="en-US"/>
    <locale android:name="fr"/>
</locale-config>
Run Code Online (Sandbox Code Playgroud)