title: android.view.InflateException: Binary XML file line #0:
body: <p>Trying to create an smart watch application opening a web view which runs some javascript code. I get a crazy: </p>
  
  <pre><code>Process: com.example.myapp.smartwatch, PID: 3308
  java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.myapp.smartwatch/com.example.myapp.smartwatch.MainActivity}: android.view.InflateException: Binary XML file line #0: Binary XML file line #0: Error inflating class android.webkit.WebView
  </code></pre>
  
  <p>Here is MWE.</p>
  
  <p>MainActivity.java:</p>
  
  <pre><code>package com.example.myapp.smartwatch;
  
  import android.os.Bundle;
  import android.support.wearable.activity.WearableActivity;
  import android.webkit.WebChromeClient;
  import android.webkit.WebSettings;
  import android.webkit.WebViewClient;
  import android.webkit.WebView;
  
  import java.util.Arrays;
  
  public class MainActivity extends WearableActivity {
  
      private WebView webview;
  
      @Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.activity_main);
  
          // Prepare webview: add zoom controls and start zoomed out
          webview = (WebView) findViewById(R.id.webview);
          final WebSettings webSettings = webview.getSettings();
          webSettings.setJavaScriptEnabled(true);
          webSettings.setBuiltInZoomControls(true);
          webSettings.setSupportZoom(true);
          webSettings.setUseWideViewPort(true);
          webview.setWebChromeClient(new WebChromeClient());
          webview.setInitialScale(1);
  
          webview.setWebViewClient(new WebViewClient() {
              @Override
              public void onPageFinished(WebView view, String url) {
                  // after the HTML page loads, run JS to initialize graph
                  int dataset[] = new int[] {5,10,15,20,35};
                  String text = Arrays.toString(dataset);
  
                  webview.loadUrl("javascript:initGraph(" + text + ", " +(webview.getHeight()) + ", " + (webview.getWidth()) + ")");
              }
          });
  
          // Load base html from the assets directory
          webview.loadUrl("file:///android_asset/html/graph.html");
      }
  }
  </code></pre>
  
  <p>activity_main.xml:</p>
  
  <pre><code>?xml version="1.0" encoding="utf-8"?&gt;
  
  &lt;android.support.wear.widget.BoxInsetLayout
      xmlns:android="http://schemas.android.com/apk/res/android"
      xmlns:app="http://schemas.android.com/apk/res-auto"
      xmlns:tools="http://schemas.android.com/tools"
      android:background="@color/dark_grey"
      android:layout_width="match_parent"
      android:layout_height="match_parent"
      tools:context="com.example.myapp.smartwatch.MainActivity"
      tools:deviceIds="wear"
      android:padding="@dimen/box_inset_layout_padding"&gt;
  
  
          &lt;WebView
              android:id="@+id/webview"
              android:layout_width="match_parent"
              android:layout_height="match_parent"
              android:layout_alignParentBottom="true"/&gt;
  
  &lt;/android.support.wear.widget.BoxInsetLayout&gt;
  </code></pre>
  
  <p>And here is the full error I get:</p>
  
  <pre><code>FATAL EXCEPTION: main
      Process: com.example.myapp.smartwatch, PID: 3308
      java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.myapp.smartwatch/com.example.myapp.smartwatch.MainActivity}: android.view.InflateException: Binary XML file line #0: Binary XML file line #0: Error inflating class android.webkit.WebView
          at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2416)
          at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2476)
          at android.app.ActivityThread.-wrap11(ActivityThread.java)
          at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1344)
          at android.os.Handler.dispatchMessage(Handler.java:102)
          at android.os.Looper.loop(Looper.java:148)
          at android.app.ActivityThread.main(ActivityThread.java:5422)
          at java.lang.reflect.Method.invoke(Native Method)
          at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
          at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
       Caused by: android.view.InflateException: Binary XML file line #0: Binary XML file line #0: Error inflating class android.webkit.WebView
          at android.view.LayoutInflater.inflate(LayoutInflater.java:539)
          at android.view.LayoutInflater.inflate(LayoutInflater.java:423)
          at android.view.LayoutInflater.inflate(LayoutInflater.java:374)
          at com.android.internal.policy.PhoneWindow.setContentView(PhoneWindow.java:393)
          at android.app.Activity.setContentView(Activity.java:2172)
          at com.example.myapp.smartwatch.MainActivity.onCreate(MainActivity.java:19)
          at android.app.Activity.performCreate(Activity.java:6251)
          at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1107)
          at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2369)
          at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2476) 
          at android.app.ActivityThread.-wrap11(ActivityThread.java) 
          at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1344) 
          at android.os.Handler.dispatchMessage(Handler.java:102) 
          at android.os.Looper.loop(Looper.java:148) 
          at android.app.ActivityThread.main(ActivityThread.java:5422) 
          at java.lang.reflect.Method.invoke(Native Method) 
          at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726) 
          at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616) 
       Caused by: android.view.InflateException: Binary XML file line #0: Error inflating class android.webkit.WebView
          at android.view.LayoutInflater.createView(LayoutInflater.java:645)
          at com.android.internal.policy.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:58)
          at android.view.LayoutInflater.onCreateView(LayoutInflater.java:694)
          at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:762)
          at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:704)
          at android.view.LayoutInflater.rInflate(LayoutInflater.java:835)
          at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:798)
          at android.view.LayoutInflater.inflate(LayoutInflater.java:515)
          at android.view.LayoutInflater.inflate(LayoutInflater.java:423) 
          at android.view.LayoutInflater.inflate(LayoutInflater.java:374) 
          at com.android.internal.policy.PhoneWindow.setContentView(PhoneWindow.java:393) 
          at android.app.Activity.setContentView(Activity.java:2172) 
          at com.example.myapp.smartwatch.MainActivity.onCreate(MainActivity.java:19) 
          at android.app.Activity.performCreate(Activity.java:6251) 
          at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1107) 
          at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2369) 
          at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2476) 
          at android.app.ActivityThread.-wrap11(ActivityThread.java) 
          at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1344) 
          at android.os.Handler.dispatchMessage(Handler.java:102) 
          at android.os.Looper.loop(Looper.java:148) 
          at android.app.ActivityThread.main(ActivityThread.java:5422) 
          at java.lang.reflect.Method.invoke(Native Method) 
          at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726) 
          at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616) 
       Caused by: java.lang.reflect.InvocationTargetException
          at java.lang.reflect.Constructor.newInstance(Native Method)
          at android.view.LayoutInflater.createView(LayoutInflater.java:619)
          at com.android.internal.policy.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:58) 
          at android.view.LayoutInflater.onCreateView(LayoutInflater.java:694) 
          at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:762) 
          at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:704) 
          at android.view.LayoutInflater.rInflate(LayoutInflater.java:835) 
          at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:798) 
          at android.view.LayoutInflater.inflate(LayoutInflater.java:515) 
          at android.view.LayoutInflater.inflate(LayoutInflater.java:423) 
          at android.view.LayoutInflater.inflate(LayoutInflater.java:374) 
          at com.android.internal.policy.PhoneWindow.setContentView(PhoneWindow.java:393) 
          at android.app.Activity.setContentView(Activity.java:2172) 
          at com.example.myapp.smartwatch.MainActivity.onCreate(MainActivity.java:19) 
          at android.app.Activity.performCreate(Activity.java:6251) 
          at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1107) 
          at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2369) 
          at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2476) 
          at android.app.ActivityThread.-wrap11(ActivityThread.java) 
          at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1344) 
          at android.os.Handler.dispatchMessage(Handler.java:102) 
          at android.os.Looper.loop(Looper.java:148) 
          at android.app.ActivityThread.main(ActivityThread.java:5422) 
          at java.lang.reflect.Method.invoke(Native Method) 
          at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726) 
          at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616) 
       Caused by: java.lang.UnsupportedOperationException
          at com.android.webview.nullwebview.NullWebViewFactoryProvider.createWebView(NullWebViewFactoryProvider.java:42)
          at android.webkit.WebView.ensureProviderCreated(WebView.java:2272)
          at android.webkit.WebView.setOverScrollMode(WebView.java:2331)
          at android.view.View.&lt;init&gt;(View.java:3795)
          at android.view.View.&lt;init&gt;(View.java:3898)
          at android.view.ViewGroup.&lt;init&gt;(ViewGroup.java:573)
          at android.widget.AbsoluteLayout.&lt;init&gt;(AbsoluteLayout.java:55)
          at android.webkit.WebView.&lt;init&gt;(WebView.java:597)
          at android.webkit.WebView.&lt;init&gt;(WebView.java:542)
          at android.webkit.WebView.&lt;init&gt;(WebView.java:525)
          at android.webkit.WebView.&lt;init&gt;(WebView.java:512)
          at java.lang.reflect.Constructor.newInstance(Native Method) 
          at android.view.LayoutInflater.createView(LayoutInflater.java:619) 
          at com.android.internal.policy.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:58) 
          at android.view.LayoutInflater.onCreateView(LayoutInflater.java:694) 
          at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:762) 
          at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:704) 
          at android.view.LayoutInflater.rInflate(LayoutInflater.java:835) 
          at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:798) 
          at android.view.LayoutInflater.inflate(LayoutInflater.java:515) 
          at android.view.LayoutInflater.inflate(LayoutInflater.java:423) 
          at android.view.LayoutInflater.inflate(LayoutInflater.java:374) 
          at com.android.internal.policy.PhoneWindow.setContentView(PhoneWindow.java:393) 
          at android.app.Activity.setContentView(Activity.java:2172) 
          at com.example.myapp.smartwatch.MainActivity.onCreate(MainActivity.java:19) 
          at android.app.Activity.performCreate(Activity.java:6251) 
          at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1107) 
          at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2369) 
          at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2476) 
          at android.app.ActivityThread.-wrap11(ActivityThread.java) 
          at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1344) 
          at android.os.Handler.dispatchMessage(Handler.java:102) 
          at android.os.Looper.loop(Looper.java:148) 
          at android.app.ActivityThread.main(ActivityThread.java:5422) 
          at java.lang.reflect.Method.invoke(Native Method) 
          at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726) 
          at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616) 
  </code></pre>
  
  <p>I have checked other threads about this error but I am in particular confused about this "line 0" on the xml file error. Would anyone know why this is happening?</p>
  
  <p>Thanks in advance</p>