问题描述
按照我的更改,在我遇到了包含视频的网络视图的问题。该问题仅在API21 +上存在,并且在删除对applyOverrideConfiguration的调用时实际上消失了。不确定如何解决。
Following my change describe in Force locale for Android flavor with resConfig I am facing a problem with webviews containing video. The issue is only on API21+ and really disappear when removing the call to applyOverrideConfiguration. Not so sure how to get around that.
java.lang.NullPointerException: Attempt to invoke virtual method 'int android.graphics.Bitmap.getWidth()' on a null object reference
at com.android.webview.chromium.WebViewContentsClientAdapter.getDefaultVideoPoster(WebViewContentsClientAdapter.java:1172)
at org.chromium.android_webview.DefaultVideoPosterRequestHandler$1.run(DefaultVideoPosterRequestHandler.java:39)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5221)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:899)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:694)
F rom我可以在grepcode上找到ic_media_video_poster图像。.我验证了该图像确实在sdk中。
From what I could find on grepcode it would be while getting the ic_media_video_poster image.. I validated that this image is really in the sdk. http://grepcode.com/file/repository.grepcode.com/java/ext/com.google.android/android/5.0.1_r1/com/android/webview/chromium/WebViewContentsClientAdapter.java#WebViewContentsClientAdapter.getDefaultVideoPoster%28%29
public Bitmap More ...getDefaultVideoPoster() {
TraceEvent.begin();
Bitmap result = null;
if (mWebChromeClient != null) {
if (TRACE) Log.d(TAG, "getDefaultVideoPoster");
result = mWebChromeClient.getDefaultVideoPoster();
}
if (result == null) {
// The ic_media_video_poster icon is transparent so we need to draw it on a gray
// background.
Bitmap poster = BitmapFactory.decodeResource(
mWebView.getContext().getResources(),
R.drawable.ic_media_video_poster);
result = Bitmap.createBitmap(poster.getWidth(), poster.getHeight(), poster.getConfig());
result.eraseColor(Color.GRAY);
Canvas canvas = new Canvas(result);
canvas.drawBitmap(poster, 0f, 0f, null);
}
TraceEvent.end();
return result;
}
编辑:经过几次测试,我能够在testApp中隔离崩溃。我在Chromium上创建的错误报告中提供了该报告,
EDIT: After a few more test, I was able to isolate the crash in a testApp. It is available in the bugreport I created on Chromium https://code.google.com/p/chromium/issues/detail?id=521753
有什么想法吗?有人遇到了这个问题吗?
Any ideas? As anyone faced this problem already?
推荐答案
就像@Martin Edlman ,它应可通过以下解决方法工作:
As @Martin Edlman commented, it should work with this workaround:
在科特林:
override fun getAssets(): AssetManager {
return resources.assets
}
在Java中:
@Override
public AssetManager getAssets() {
return getResources().getAssets();
}
这篇关于Chromium Webview似乎不适用于Android applyOverrideConfiguration的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!