版本库迁移至AndroidX后,WebView在5.0&5.1设备上引起App崩溃
当前AndroidX版本1.1.0
两个方案:
1、针对WebView复写
public class LollipopFixedWebView extends WebView {
public LollipopFixedWebView(Context context) {
super(getFixedContext(context));
}
public LollipopFixedWebView(Context context, AttributeSet attrs) {
super(getFixedContext(context), attrs);
}
public LollipopFixedWebView(Context context, AttributeSet attrs, int defStyleAttr) {
super(getFixedContext(context), attrs, defStyleAttr);
}
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
public LollipopFixedWebView(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
super(getFixedContext(context), attrs, defStyleAttr, defStyleRes);
}
public static Context getFixedContext(Context context) {
if (Build.VERSION.SDK_INT >= 21 && Build.VERSION.SDK_INT < 23) // Android Lollipop 5.0 & 5.1
return context.createConfigurationContext(new Configuration());
return context;
}
}
2、回退版本1.0.2/1.0.0
1.0.0就是support28的版本内容
针对AndroidX版本1.1.0在5.0&5.1设备上导致App崩溃的问题,提供两种解决方案:1.通过复写WebView类,适配Lollipop系统;2.将AndroidX版本回退至1.0.2或1.0.0。
1913

被折叠的 条评论
为什么被折叠?



