The bitmap null pointer when the WebViewContentsClientAdapter of Webveiw gets the width and height of bitmap

java.lang.NullPointerException

Attempt to invoke virtual method "int android.graphics.Bitmap.getWidth ()" on a null object reference

parse the original
1 com.android.webview.chromium.WebViewContentsClientAdapter.getDefaultVideoPoster (WebViewContentsClientAdapter.java:596)
2 org.chromium.android_webview.DefaultVideoPosterRequestHandler$$Lambda$0.run (Unknown Source:2)
3 android.os.Handler.handleCallback (Handler.java:808)
4 android.os.Handler.dispatchMessage (Handler.java:101)
5 android.os.Looper.loop (Looper.java:166)
6 android.app.ActivityThread.main (ActivityThread.java:7425)
7 java.lang.reflect.Method.invoke (Native Method)
8 com.android .room.os.Zygote $MethodAndArgsCaller.run (Zygote.java:245)
9 com.android.internal.os.ZygoteInit.main (ZygoteInit.java:921)

Mar.25,2021

https://blog.csdn.net/Ltp_zy/. has found a solution. I don't know if you have used it. Please answer


for now.

Here's a workaround for the problem:

Add to your MainActivity:

@Override
public AssetManager getAssets() {
    return getResources().getAssets();
}

we know what's causing this, but fixing it is non-trivial at this point in M development. The workaround should be ok though.

official circumvention scheme of chrome
https://bugs.chromium.org/p/c.

Menu