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

crash on using webview #105

Open
Open

Description

@hsiami

when I change locale and then use webview app crashes for the first time.

var webview = WebView(this)

java.lang.RuntimeException: Package not found: com.android.webview
    at android.webkit.WebViewDelegate.getPackageId(WebViewDelegate.java:191)
    at lb.a(PG:16)
    at ks.run(PG:14)
    at java.lang.Thread.run(Thread.java:919)

Activity

  1. changed the title [-]crash when using webview[/-] [+]crash on using webview[/+] on Apr 20, 2021
  2. akexorcist commented on Apr 20, 2021

    @akexorcist
    Owner

    @hsiami Did you tried to test on Android Emulator or Physical device?

  3. akexorcist commented on Apr 20, 2021

    @akexorcist
    Owner

    Refer to stack trace from https://stackoverflow.com/questions/47944586/package-not-found-com-android-chrome

    java.lang.RuntimeException: Package not found: com.android.chrome
        at android.webkit.WebViewDelegate.getPackageId(WebViewDelegate.java:164)
        at com.android.webview.chromium.ig.L(WebViewDelegateFactory.java:16)
        at com.android.webview.chromium.WebViewChromiumFactoryProvider.h(WebViewChromiumFactoryProvider.java:177)
        at com.android.webview.chromium.se.run(WebViewChromiumFactoryProvider.java:5)
        at android.os.Handler.handleCallback(Handler.java:789)
        at android.os.Handler.dispatchMessage(Handler.java:98)
        at android.os.Looper.loop(Looper.java:164)
        at android.app.ActivityThread.main(ActivityThread.java:6809)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:240)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:767)
    

    This seems not related to my library. But I will keep this issue because crashing might caused by Resource class from my library.

    /**
     * Returns the package id of the given {@code packageName}.
     */
    public int getPackageId(Resources resources, String packageName) {
        SparseArray<String> packageIdentifiers =
                resources.getAssets().getAssignedPackageIdentifiers();
        for (int i = 0; i < packageIdentifiers.size(); i++) {
            final String name = packageIdentifiers.valueAt(i);
            if (packageName.equals(name)) {
                return packageIdentifiers.keyAt(i);
            }
        }
        throw new RuntimeException("Package not found: " + packageName);
    }
  4. hsiami commented on Apr 20, 2021

    @hsiami
    Author

    @hsiami Did you tried to test on Android Emulator or Physical device?

    I tried on both Emulator and physical device

  5. hsiami commented on Apr 21, 2021

    @hsiami
    Author

    Without your library app doesn't crash. and with your library app crashes only when I change the locale and then create an instance of WebView.

    No idea yet?

  6. hsiami commented on Apr 22, 2021

    @hsiami
    Author

    for solving webview problem I used this library instead:
    https://github.com/YarikSOffice/lingver

  7. akexorcist commented on Apr 27, 2021

    @akexorcist
    Owner

    @hsiami Thank you for alternative library suggestion.

    I will fix this issue soon. In Lingver library, there're some information about WebView issue that might useful for me to solve this issue.

  8. omidahmadian commented on May 10, 2021

    @omidahmadian

    I also have this problem
    Did you find any solution for it?

    @hsiami Thank you for alternative library suggestion.

    I will fix this issue soon. In Lingver library, there're some information about WebView issue that might useful for me to solve this issue.

  9. hsiami commented on May 10, 2021

    @hsiami
    Author

    I also have this problem
    Did you find any solution for it?

    @hsiami Thank you for alternative library suggestion.
    I will fix this issue soon. In Lingver library, there're some information about WebView issue that might useful for me to solve this issue.

    for solving webview problem I used this library instead:
    https://github.com/YarikSOffice/lingver

  10. ashutoshgohil commented on May 11, 2021

    @ashutoshgohil

    It's crashing on webview randomly.

  11. nagesh-kashyap-r commented on May 11, 2021

    @nagesh-kashyap-r

    @akexorcist I can see you have resolved the crash issue (saw in commits)
    but when I try updating library from 1.2.9 -> 1.2.10 but ended with the following error.
    Could not find com.akexorcist:localization:1.2.10.

  12. akexorcist commented on May 11, 2021

    @akexorcist
    Owner

    @nagesh-kashyap-r still in testing please wait until tomorrow

  13. akexorcist commented on May 11, 2021

    @akexorcist
    Owner

    1.2.10 is live. please check on your project and don't forget to give me a feedback.

  14. nagesh-kashyap-r commented on May 11, 2021

    @nagesh-kashyap-r

    @akexorcist Thanks!!!! Crash issue is resolved!

  15. huunhan18pro commented on May 25, 2021

    @huunhan18pro

    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

  16. juliocbcotta commented on Jul 13, 2021

    @juliocbcotta

    @akexorcist I have tried the 1.2.10 and I get the error when creating an instance of WebView or just setting it to debug.
    I tried to replicate it in the sample app in the repository, but I couldn't.

    Do you have any tips ?

  17. MobatiaArshad commented on Jul 23, 2021

    @MobatiaArshad

    This crash issue is still rising with version com.akexorcist:localization:1.2.10. The crash is only occurring when user try to open the webView with fresh install.

  18. fukemy commented on Nov 11, 2021

    @fukemy

    for solving webview problem I used this library instead: https://github.com/YarikSOffice/lingver

    lingver is better. Thanks

  19. akexorcist commented on Dec 7, 2021

    @akexorcist
    Owner

    Note:
    From my investigation, this happen when user change the language to another language then open WebView.

    webview-crash.mp4

    Let me investigate more about it.

  20. akexorcist commented on Dec 21, 2021

    @akexorcist
    Owner

    This issue was fixed in 1.2.11. Please check it out

  21. kenkieo commented on May 5, 2022

    @kenkieo

    i guess u just code locazation,and u just only Override application.getResources but not Override getAssets.
    why it happen by locazation, we can see the android framewrok :
    WebViewFactoryProvider.getProvider -> WebViewFactoryProvider.getProviderClass-> AppGlobals.getInitialApplication (the application u config manifest.xml)-> initialApplication.getAssets().addAssetPathAsSharedLibrary (this webview package info add to ).

  22. akexorcist commented on Jun 21, 2022

    @akexorcist
    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 join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions