appcompat:1.1.0 사용중인 경우, Android OS Ver. lollipop 에서 웹뷰 오류가 발생한다
Fatal Exception: java.lang.RuntimeException: Unable to start activity ComponentInfo ...
... Binary XML file ... webview
간단한 해결 법은 두 개정도.
1st. minSdk 상향 조정 : 21 -> 23
2st. lollipop 분기 처리
- 단, 분기 처리는 하위 버전을 분기하여 관리하는 품이 하나 더 늘어나는 단점이 있다.
implementation 'androidx.appcompat:appcompat:1.1.0'
import android.content.Context;
import android.content.res.Configuration;
import android.os.Build;
import android.util.AttributeSet;
import android.webkit.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);
}
// To fix Android Lollipop WebView problem create a new configuration on that Android version only
private static Context getFixedContext(Context context) {
if (Build.VERSION.SDK_INT == 21 || Build.VERSION.SDK_INT == 22) // Android Lollipop 5.0 & 5.1
return context.createConfigurationContext(new Configuration());
return context;
}
}
'안드로이드 > Error' 카테고리의 다른 글
[android][error] Doze mode / Service / AlarmManager (0) | 2020.03.26 |
---|---|
[android][error]bluetooth scancallback (0) | 2020.03.19 |
[Android, error] androidx 적용 (0) | 2019.03.21 |
[Android][error] kotlinx.coroutines error (0) | 2019.03.11 |
[android][error]project refresh failed - cache.properties.lock (0) | 2015.11.19 |