Localization icon indicating copy to clipboard operation
Localization copied to clipboard

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

Open CNdev16 opened this issue 3 years ago • 11 comments

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)

CNdev16 avatar May 25 '21 07:05 CNdev16

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

huunhan18pro avatar May 25 '21 13:05 huunhan18pro

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

nagesh-kashyap-r avatar May 27 '21 07:05 nagesh-kashyap-r

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

nagesh-kashyap-r avatar May 27 '21 12:05 nagesh-kashyap-r

any one have solution for this. The same issue here

Stupidman22 avatar Jun 06 '21 14:06 Stupidman22

@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.

nagesh-kashyap-r avatar Jun 06 '21 15:06 nagesh-kashyap-r

Thank you so much. I will apply it 😁

On Sun, Jun 6, 2021, 22:44 nagesh-kashyap-r @.***> wrote:

@Stupidman22 https://github.com/Stupidman22 @huunhan18pro https://github.com/huunhan18pro @CNdev16 https://github.com/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.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/akexorcist/Localization/issues/114#issuecomment-855419073, or unsubscribe https://github.com/notifications/unsubscribe-auth/ACAGR55665YZZC7J44HLS6LTROJV5ANCNFSM45OXTLCQ .

Stupidman22 avatar Jun 06 '21 15:06 Stupidman22

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

Stupidman22 avatar Jun 07 '21 14:06 Stupidman22

@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?

nagesh-kashyap-r avatar Jun 07 '21 15:06 nagesh-kashyap-r

@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 :( ...

Stupidman22 avatar Jun 07 '21 15:06 Stupidman22

This issue was fixed in 1.2.11. Please check it out

akexorcist avatar Dec 21 '21 19:12 akexorcist

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

akexorcist avatar Jun 21 '22 21:06 akexorcist