title: java.lang.ClassCastException: android.support.v7.widget.ActivityChooserView$InnerLayout cannot be cast to android.support.v7.widget.LinearLayoutCompat
body: <p>Switching from LinearLayout to ConstraintLayout throwing this error</p>
  
  <pre><code>java.lang.ClassCastException: android.support.v7.widget.ActivityChooserView$InnerLayout cannot be cast to android.support.v7.widget.LinearLayoutCompat                                                                                                                                             
  </code></pre>
  
  <p>The error occurs when i try to inflate the menu in <code>onCreateOptionsMenu()</code> in my fragment.</p>
  
  <p>My menu which I inflate :-</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;menu xmlns:android="http://schemas.android.com/apk/res/android"
      xmlns:app="http://schemas.android.com/apk/res-auto"&gt;   
      &lt;item
          android:id="@+id/action_share"
          app:showAsAction="always"
          android:orderInCategory="101"
          android:icon="@android:drawable/ic_menu_share"
          android:title="@string/action_share"
          app:actionProviderClass="android.support.v7.widget.ShareActionProvider"
          /&gt;
  &lt;/menu&gt;</code></pre>
  </div>
  </div>
  </p>
  
  <p>My <code>onCreateOptionsMenu(..)</code> </p>
  
  <pre><code>@Override
  public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {     
      inflater.inflate(R.menu.customerdetail, menu);      
      MenuItem menuItem = menu.findItem(R.id.action_share);
      mShareActionProvider = (ShareActionProvider) 
      MenuItemCompat.getActionProvider(menuItem);         
   // If i comment out this whole part everything is fine !!
   }
  </code></pre>
  
  <p><strong>Edit</strong> :- ScreenShot of the log:-</p>
  
  <p><a href="https://i.stack.imgur.com/VsqRQ.png" rel="noreferrer"><img src="https://i.stack.imgur.com/VsqRQ.png" alt="enter image description here"></a></p>
  
  <p><strong>Update</strong> :- Adding the <code>app:actionProviderClass="android.support.v7.widget.ShareActionProvider"</code> item causes the error. </p>
  
  <p>As suggested by ShaneCoder dropping down to <code>27.0.2</code> / changing to <code>LinearLayout</code> removes the error but i want to know </p>
  
  <blockquote>
    <p>Why is <code>27.1.0</code> is throwing such error at runtime while inflating Class,<code>android.support.v7.widget.ShareActionProvider</code> ? (is it a bug in <code>27.1.0</code> )</p>
  </blockquote>