Skip to content
This repository has been archived by the owner on Jun 22, 2022. It is now read-only.

App crashes first time using web view after setting a new language in the application. #114

Open
CNdev16 opened this issue May 25, 2021 · 11 comments
Labels

Comments

@CNdev16
Copy link

CNdev16 commented May 25, 2021

App crashes first time using web view after setting a new language in the application.
แอพจะแครชกรณีใช้งาน webview ครั้งแรกหลังจาก start app -> set language in app ครับ

ref:

  • using ver. 1.2.10
  • java.lang.RuntimeException: Package not found: com.android.chrome
    at android.webkit.WebViewDelegate.getPackageId(WebViewDelegate.java:164)
    at xH.a(PG:16)
    at xg.run(PG:14)
    at java.lang.Thread.run(Thread.java:764)
@huunhan18pro
Copy link

I also get the same issue. Only for the first time. The library is very good. I could change any language on my app. But I got this issue. Hope you fix it soon. Ver 1.2.10 and Android 7.0

@nagesh-kashyap-r
Copy link

nagesh-kashyap-r commented May 27, 2021

@akexorcist i'm facing same issue. App crashes for first time.

@nagesh-kashyap-r
Copy link

@akexorcist I found the scenario. if I change locale after retuning a different locale from getDefaultLanguage(base: Context). (for very first time)

@Stupidman22
Copy link

any one have solution for this. The same issue here

@nagesh-kashyap-r
Copy link

nagesh-kashyap-r commented Jun 6, 2021

@Stupidman22 @huunhan18pro @CNdev16 I resolved this issue.

You have to create a webview instance (programmatically) and destroy it. (just do it in on create).
Find the helper class in the below link.

https://github.com/YarikSOffice/lingver/blob/master/sample/src/main/java/com/yariksoffice/lingver/WebViewLocaleHelper.kt

Not sure why it behaves like this. but it solved my problem.

Crash happens only if you inflate a webview via XML (first instance).
Not sure, but maybe it is something to do with not refreshing application context after language change.

Please let me know if it resolves your issue.

@Stupidman22
Copy link

Stupidman22 commented Jun 6, 2021 via email

@Stupidman22
Copy link

Stupidman22 commented Jun 7, 2021

The problem cause when using web view and override this function at application
override fun getDefaultLanguage(): Locale {
return Locale.getDefault()
}
--> any one try to reproduce and fix issue pls. I think this is critical issue

@nagesh-kashyap-r
Copy link

nagesh-kashyap-r commented Jun 7, 2021

@Stupidman22 I solved the exact same issue by just creating an WebView() object.

Like WebView(context).destroy() ->> in onCreate() of activity

Did you try this?

@Stupidman22
Copy link

@nagesh-kashyap-r : In my case the webview is Native ads of google. It load in activity first time. I try to using your solution. But it FC. I think I did something wrong :( ...

@akexorcist
Copy link
Owner

This issue was fixed in 1.2.11. Please check it out

@akexorcist
Copy link
Owner

Since AndroidX AppCompat has per-app language preferences for backward compatibility. Please migrate this library to AndroidX for more stability, compatibility, and longer support from Google team.

See Migrate to AndroidX guide

Thank you for your support

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

5 participants