I am trying to upgrade my gradle. When i updated the appcompat from 1.0.2 to 1.1.0, my webview didnt work anymore on certain phones. (api 21 and 22).
Is there a smart way to upgrade to 1.1.0 and still make the webview work.
I get an 'android.view.InflateException: Binary XML file line #1: Error inflating class '. I have tried to find a way to update the webview on my emulators. But i really hope for a code that either way fixes the problem, for users that dont update the webview.
my xml:
<WebView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/webview"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
/>
My Activity:
private WebView mWebView;
private String state;
@SuppressLint("SetJavaScriptEnabled")
@Override
protected void onCreate(Bundle savedInstanceState) {
try {
super.onCreate(savedInstanceState);
setContentView(R.layout.login_webview_activity);
mWebView = findViewById(R.id.webview);
mWebView.setWebViewClient(new MyBrowser());
WebSettings settings = mWebView.getSettings();
settings.setJavaScriptEnabled(true);
settings.setDomStorageEnabled(true);
CookieManager.getInstance().setAcceptCookie(true);
CookieManager.getInstance().setAcceptThirdPartyCookies(mWebView, true);
mWebView.setScrollBarStyle(View.SCROLLBARS_INSIDE_OVERLAY);
My error:
WebViewActivity: android.view.InflateException: Binary XML file line #1: Error inflating class android.webkit.WebView
at android.view.LayoutInflater.createView(LayoutInflater.java:633)
at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:55)
at android.view.LayoutInflater.onCreateView(LayoutInflater.java:682)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:741)
at android.view.LayoutInflater.inflate(LayoutInflater.java:482)
at android.view.LayoutInflater.inflate(LayoutInflater.java:414)
at android.view.LayoutInflater.inflate(LayoutInflater.java:365)
at androidx.appcompat.app.AppCompatDelegateImpl.setContentView(AppCompatDelegateImpl.java:555)
at androidx.appcompat.app.AppCompatActivity.setContentView(AppCompatActivity.java:161)
at no.posten.sporing.controller.activity.WebViewActivity.onCreate(WebViewActivity.java:53)
at android.app.Activity.performCreate(Activity.java:5937)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1105)
And again- appcompat 1.0.2 works like a charm, but not 1.1.0.