Bugly遇到異常
查找原因,分析發現崩潰發生在Android版本21和22上,在網上查找資料發現下面解決方案
使用自定義WebView替換原生自帶WebView解決
package com.test.test;
import android.content.Context;
import android.content.res.Configuration;
import android.os.Build;
import android.util.AttributeSet;
import android.webkit.WebView;
public class CustomWebView extends WebView {
public CustomWebView(Context context) {
super(getFixedContext(context));
}
public CustomWebView(Context context, AttributeSet attrs) {
super(getFixedContext(context), attrs);
}
public CustomWebView(Context context, AttributeSet attrs, int defStyleAttr) {
super(getFixedContext(context), attrs, defStyleAttr);
}
public static Context getFixedContext(Context context) {
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.M) {
return context.createConfigurationContext(new Configuration());
} else {
return context;
}
}
}
替換后WebView能打開了,可是又遇到了新的問題,WebView讀取html select下拉框標簽出現崩潰
解決方案,繼續使用原生WebView
由版本implementation 'androidx.appcompat:appcompat:1.1.0'版本
修改版本至implementation 'androidx.appcompat:appcompat:1.0.2'解決