akexorcist / Localization

[Android] In-app language changing library
Apache License 2.0
983 stars 154 forks source link

App crashes when using WebView even after updating to v1.2.10 #118

Open mahbub-alam opened 3 years ago

mahbub-alam commented 3 years ago

I am playing YouTube video in an activity using WebView. I am using this library for language change. There are two languages. When language is changed from default to 2nd language, going to that activity crashes the app (inflating exception).

Previously, inflating exception didn't mention the "Package not found" exception; but, I found it hidden way deep in "cause" field of the stack trace.

So, to fix that, I used the latest update v1.2.10 to fix the WebView crash. It worked on some devices. But, this one below is happening in other devices. And now the exception directly shows "Package not found".

This exception is from "Android 8.1.0, Huawei, Nexus 6P".

The stack trace below-

Caused by java.lang.RuntimeException: Package not found: com.android.chrome
       at android.webkit.WebViewDelegate.getPackageId(WebViewDelegate.java:164)
       at vH4.getPackageId(vH4.java:1)
       at com.android.webview.chromium.WebViewChromiumFactoryProvider.f(WebViewChromiumFactoryProvider.java:34)
       at com.android.webview.chromium.WebViewChromiumFactoryProvider.<init>(WebViewChromiumFactoryProvider.java:12)
       at com.android.webview.chromium.WebViewChromiumFactoryProviderForOMR1.<init>(WebViewChromiumFactoryProviderForOMR1.java:1)
       at com.android.webview.chromium.WebViewChromiumFactoryProviderForOMR1.create(WebViewChromiumFactoryProviderForOMR1.java:1)
       at java.lang.reflect.Method.invoke(Method.java)
       at android.webkit.WebViewFactory.getProvider(WebViewFactory.java:208)
       at android.webkit.WebView.getFactory(WebView.java:2530)
       at android.webkit.WebView.ensureProviderCreated(WebView.java:2525)
       at android.webkit.WebView.setOverScrollMode(WebView.java:2590)
       at android.view.View.<init>(View.java:4574)
       at android.view.View.<init>(View.java:4706)
       at android.view.ViewGroup.<init>(ViewGroup.java:597)
       at android.widget.AbsoluteLayout.<init>(AbsoluteLayout.java:55)
       at android.webkit.WebView.<init>(WebView.java:643)
       at android.webkit.WebView.<init>(WebView.java:588)
       at android.webkit.WebView.<init>(WebView.java:571)
       at android.webkit.WebView.<init>(WebView.java:558)
       at java.lang.reflect.Constructor.newInstance0(Constructor.java)
       at java.lang.reflect.Constructor.newInstance(Constructor.java:334)
       at android.view.LayoutInflater.createView(LayoutInflater.java:647)
       at com.android.internal.policy.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:58)
       at android.view.LayoutInflater.onCreateView(LayoutInflater.java:720)
       at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:788)
       at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:730)
       at android.view.LayoutInflater.rInflate(LayoutInflater.java:863)
       at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:824)
       at android.view.LayoutInflater.inflate(LayoutInflater.java:515)
       at android.view.LayoutInflater.inflate(LayoutInflater.java:423)
       at android.view.LayoutInflater.inflate(LayoutInflater.java:374)
       at androidx.appcompat.app.AppCompatDelegateImpl.setContentView(AppCompatDelegateImpl.java:699)
       at androidx.appcompat.app.AppCompatActivity.setContentView(AppCompatActivity.java:195)
       at com.example.mobile.views.activities.BaseActivity.onCreate(BaseActivity.java:35)
       at com.example.mobile.views.activities.PlayTutorialActivity.onCreate(PlayTutorialActivity.java:22)
       at android.app.Activity.performCreate(Activity.java:7009)
       at android.app.Activity.performCreate(Activity.java:7000)
       at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1214)
       at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2731)
       at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2856)
       at android.app.ActivityThread.-wrap11(ActivityThread.java)
       at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1589)
       at android.os.Handler.dispatchMessage(Handler.java:106)
       at android.os.Looper.loop(Looper.java:164)
       at android.app.ActivityThread.main(ActivityThread.java:6494)
       at java.lang.reflect.Method.invoke(Method.java)
       at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:438)
       at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:807)
hassanien96 commented 3 years ago

Same problem for me

hassanien96 commented 3 years ago

i solved it by putting
WebView(this).destroy() in my application class

akexorcist commented 2 years ago

This issue was fixed in 1.2.11. Please check it out

akexorcist commented 2 years ago

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