title: Xamarin:Unable to convert instance of type Android.Widget.LinearLayout to type Android.Support.V7.Widget.Toolbar
body: <p>The app is running on Android 6 or below. But when running on Android 7 (Nougat) it throws runtime exception.</p>
  
  <pre><code>System.InvalidCastException: Unable to convert instance of type 'Android.Widget.LinearLayout' to type 'Android.Support.V7.Widget.Toolbar'.
  </code></pre>
  
  <p>The error is thrown in Xamarin (Visual studio 2017) at below code:</p>
  
  <pre><code>public class MainActivity : global::Xamarin.Forms.Platform.Android.FormsAppCompatActivity
  {
      protected override void OnCreate(Bundle bundle)
      {
          ToolbarResource = Resource.Layout.toolbar;
          TabLayoutResource = Resource.Layout.tabs;
  
          base.OnCreate(bundle); //Runtime error here
          .... Other code ...
      }
  }
  </code></pre>
  
  <p>I've taken latest updates for All Nuget packages but not able to identify the issue. For testing I'm using Moto G4+ (Android 7.0).
  Can anybody help please?</p>
  
  <p><strong>Edit 1:</strong></p>
  
  <p>Layout of toolbar is as : (Under resources > layout > toolbar.axml). This was already there when App version with Android 6 released. But Now visited app back for Android 7 issues.</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;android.support.v7.widget.Toolbar xmlns:android="http://schemas.android.com/apk/res/android"
      xmlns:app="http://schemas.android.com/apk/res-auto"
      android:id="@+id/toolbar" 
      android:layout_width="match_parent"
      android:layout_height="?attr/actionBarSize"
      android:minHeight="?attr/actionBarSize"
      android:background="?attr/colorPrimary"
      android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
      app:popupTheme="@style/ThemeOverlay.AppCompat.Light" /&gt;
  </code></pre>