title: Failed to find style in current theme for custom view with defStyleAttr
body: <p>I have a custom view which also uses its own <code>defStyleAttr</code> i.e.</p>
  
  <blockquote>
    <p>An attribute in the current theme that contains a reference to a style resource that supplies default values for the view.</p>
  </blockquote>
  
  <p>When declaring this view in a layout file and clicking Preview in Android Studio 2.2.3 I get the following error message:</p>
  
  <blockquote>
    <p>Missing styles. Is the correct theme chosen for this layout?Use the Theme combo box above the layout to choose a different layout, or fix the theme style references.Failed to find style 'myCustomStyleAttr' in current theme</p>
  </blockquote>
  
  <p>My view constructors are:</p>
  
  <pre><code>public MyCustomLayout(Context context) {
      this(context, null);
  }
  
  public MyCustomLayout(Context context, AttributeSet attrs) {
      this(context, attrs, R.attr.myCustomStyleAttr);
  }
  
  public MyCustomLayout(Context context, AttributeSet attrs, int defStyleAttr) {
      super(context, attrs, defStyleAttr);
      init(attrs, defStyleAttr);
  }
  </code></pre>
  
  <p>I know there are a lot of questions on SO with the <em>Missing styles.</em> error however none of the answers worked for me and they were mostly related to AppCompat styles so I wanted to share my solution.</p>