更新到 androidx.appcompat:appcompat:1.1.0 后的语言更改问题 [英] Language change issue after updating to androidx.appcompat:appcompat:1.1.0

查看:49
本文介绍了更新到 androidx.appcompat:appcompat:1.1.0 后的语言更改问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

最新app-compat的链接是1.1.0.

将我的应用升级到最新的 app-compat 后,我的语言设置在 API 24 以下的手机上停止工作(粗略地说,不适用于 API 21 及以下的手机)当然).

对于 API 24 及更高版本,我使用了 ContextWrapper 并设置了 locale 因此有效.

我的问题是如果 androidx.appcompat:appcompat:1.1.0 是稳定版本,为什么它在 alphabeta 版本不同于这里的其他版本 &我试过的问题.

<块引用>

是不是要等官方稳定版再降级最后一个稳定版本或者哪个是让谷歌的有效方式知道是否有(当然,我知道要提交错误)?

解决方案

要继续使用 1.1.0 版,请在您的 attachBaseContext 下方添加:

Kotlin 解决方案:

override fun applyOverrideConfiguration(overrideConfiguration: Configuration?) {如果(覆盖配置!= null){val uiMode = overrideConfiguration.uiModeoverrideConfiguration.setTo(baseContext.resources.configuration)overrideConfiguration.uiMode = uiMode}super.applyOverrideConfiguration(overrideConfiguration)}

Java 解决方案:

@Override公共无效应用覆盖配置(配置覆盖配置){如果(覆盖配置!= null){int uiMode = overrideConfiguration.uiMode;overrideConfiguration.setTo(getBaseContext().getResources().getConfiguration());overrideConfiguration.uiMode = uiMode;}super.applyOverrideConfiguration(overrideConfiguration);}

<块引用>

如果您不需要升级到最新的 appCompat 然后检查旧答案.否则使用@0101100101 提供的解决方案此处.

旧答案:

花了几个小时尝试后,才知道这可能是一个错误.

降级到最后一个稳定版本,它可以完美运行.

依赖项{implementation 'androidx.appcompat:appcompat:1.0.2'//************ 请勿在 API 23 及以下版本上升级语言问题 *********************//实现 'androidx.legacy:legacy-support-v4:1.0.0'....}

与此同时,我已经向 Google 提交了一个问题 https://issuetracker.google.com/issues/140880275

The link of the latest app-compat which is 1.1.0.

After upgrading my app to the latest app-compat my language settings stopped working for phones below API 24 (roughly, doesn't work on API 21 and below for sure).

For API 24 and above, I have used the ContextWrapper and set the locale hence works.

My question is if the androidx.appcompat:appcompat:1.1.0is the stable version why does it work for me in alpha and beta versions unlike the others here & the questions which I have tried.

Should I wait for an official stable version again and downgrade to the last stable version or which is the efficient way to let google know if any(ofcourse, I know to file a bug)?

解决方案

Edit:

To continue using version 1.1.0 add this below your attachBaseContext:

Kotlin solution:

override fun applyOverrideConfiguration(overrideConfiguration: Configuration?) {
    if (overrideConfiguration != null) {
        val uiMode = overrideConfiguration.uiMode
        overrideConfiguration.setTo(baseContext.resources.configuration)
        overrideConfiguration.uiMode = uiMode
    }
    super.applyOverrideConfiguration(overrideConfiguration)
}

Java solution:

@Override
public void applyOverrideConfiguration(Configuration overrideConfiguration) {
    if (overrideConfiguration != null) {
        int uiMode = overrideConfiguration.uiMode;
        overrideConfiguration.setTo(getBaseContext().getResources().getConfiguration());
        overrideConfiguration.uiMode = uiMode;
    }
    super.applyOverrideConfiguration(overrideConfiguration);
}

If you don't need to upgrade to the latest appCompat then check the old answer. Else use the solution provided by @0101100101 here.

Old Answer:

After spending hours trying, got to know that it might be a bug.

Downgrade to the last stable version and it works flawlessly.

dependencies {
    implementation 'androidx.appcompat:appcompat:1.0.2'   //************ DO NOT UPGRADE LANGUAGE ISSUE on API 23 and below *******************//
    implementation 'androidx.legacy:legacy-support-v4:1.0.0'
....
}

Meanwhile, I have filed an issue with Google https://issuetracker.google.com/issues/140880275

这篇关于更新到 androidx.appcompat:appcompat:1.1.0 后的语言更改问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆