title: Java.Lang.IllegalStateException while using FormsAppCompatActivity in Xamarin Android
body: <p>The Xamarin android code is giving runtime exception when used with following code:</p>
  
  <pre><code>public class MyActivity: global::Xamarin.Forms.Platform.Android.FormsAppCompatActivity
  {
      protected override void OnCreate(Bundle bundle)
      {
          ToolbarResource = Resource.Layout.toolbar;
          TabLayoutResource = Resource.Layout.tabs;
          base.OnCreate(bundle);
  
          global::Xamarin.Forms.Forms.Init(this, bundle);
          LoadApplication(new App());            
      }
  }
  </code></pre>
  
  <p>When running the app, its builds successfully. But in Runtime iot gets into following error StackTrace:</p>
  
  <pre><code>Java.Lang.IllegalStateException: Exception of type 'Java.Lang.IllegalStateException' was thrown.
  at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () &lt;IL 0x00011, 0x00078&gt;
  at Android.Runtime.JNIEnv.CallIntMethod (intptr,intptr) &lt;IL 0x00069, 0x00297&gt;
  at Android.Support.V4.App.FragmentTransactionInvoker.Commit () &lt;IL 0x00038, 0x00143&gt;
  at Xamarin.Forms.Platform.Android.AppCompat.NavigationPageRenderer.SwitchContentAsync (Xamarin.Forms.Page,bool,bool,bool) &lt;IL 0x00140, 0x00953&gt;
  at Xamarin.Forms.Platform.Android.AppCompat.NavigationPageRenderer.OnPushAsync (Xamarin.Forms.Page,bool) &lt;IL 0x00005, 0x00063&gt;
  at Xamarin.Forms.Platform.Android.AppCompat.NavigationPageRenderer.PushViewAsync (Xamarin.Forms.Page,bool) &lt;IL 0x00003, 0x00053&gt;
  at Xamarin.Forms.Platform.Android.AppCompat.NavigationPageRenderer.&lt;OnElementChanged&gt;b__13_0 (Xamarin.Forms.Page) &lt;IL 0x00003, 0x0004f&gt;
  at Xamarin.Forms.EnumerableExtensions.ForEach&lt;Xamarin.Forms.Page&gt; (System.Collections.Generic.IEnumerable`1&lt;Xamarin.Forms.Page&gt;,System.Action`1&lt;Xamarin.Forms.Page&gt;) &lt;0x00157&gt;
  An unhandled exception occured.
  
  at Xamarin.Forms.Platform.Android.AppCompat.NavigationPageRenderer.OnElementChanged (Xamarin.Forms.Platform.Android.ElementChangedEventArgs`1&lt;Xamarin.Forms.NavigationPage&gt;) &lt;IL 0x001bb, 0x00e0f&gt;
  at Xamarin.Forms.Platform.Android.VisualElementRenderer`1&lt;Xamarin.Forms.NavigationPage&gt;.SetElement (Xamarin.Forms.NavigationPage) &lt;0x00827&gt;
  at Xamarin.Forms.Platform.Android.VisualElementRenderer`1&lt;Xamarin.Forms.NavigationPage&gt;.Xamarin.Forms.Platform.Android.IVisualElementRenderer.SetElement (Xamarin.Forms.VisualElement) &lt;0x0012b&gt;
  at Xamarin.Forms.Platform.Android.Platform.CreateRenderer (Xamarin.Forms.VisualElement) &lt;IL 0x00021, 0x0014f&gt;
  at Xamarin.Forms.Platform.Android.MasterDetailContainer.set_ChildView (Xamarin.Forms.VisualElement) &lt;IL 0x00049, 0x001df&gt;
  at Xamarin.Forms.Platform.Android.AppCompat.MasterDetailPageRenderer.UpdateDetail () &lt;IL 0x0001d, 0x000e3&gt;
  at Xamarin.Forms.Platform.Android.AppCompat.MasterDetailPageRenderer.HandlePropertyChanged (object,System.ComponentModel.PropertyChangedEventArgs) &lt;IL 0x0002c, 0x00157&gt;
  at (wrapper delegate-invoke) &lt;Module&gt;.invoke_void_object_PropertyChangedEventArgs (object,System.ComponentModel.PropertyChangedEventArgs) &lt;IL 0x0002f, 0x0008b&gt;
  at Xamarin.Forms.BindableObject.OnPropertyChanged (string) &lt;IL 0x00012, 0x000d7&gt;
  at Xamarin.Forms.Element.OnPropertyChanged (string) &lt;IL 0x00002, 0x0005f&gt;
  at Xamarin.Forms.MasterDetailPage.set_Detail (Xamarin.Forms.Page) &lt;IL 0x0007b, 0x002eb&gt;
  at eWorker.App.SetRootPage (Xamarin.Forms.Page) [0x00025] in C:\SIProducts\360\Dev\Frontend\BugFixes\Source\BIF\Source\eWorker\XamarinApp\Shared\eWorkerShared\App.cs:97
  at eWorker.Views.HomePage.OnAppearing () [0x0000e] in C:\SIProducts\360\Dev\Frontend\BugFixes\Source\BIF\Source\eWorker\XamarinApp\Shared\eWorkerShared\Views\HomePage.cs:39
  at Xamarin.Forms.Page.SendAppearing () &lt;IL 0x00025, 0x0011f&gt;
  at Xamarin.Forms.Platform.Android.AppCompat.FragmentContainer.set_UserVisibleHint (bool) &lt;IL 0x0004b, 0x002a3&gt;
  at Xamarin.Forms.Platform.Android.AppCompat.NavigationPageRenderer/&lt;&gt;c__DisplayClass52_0.&lt;SwitchContentAsync&gt;b__1 () &lt;IL 0x00014, 0x0008f&gt;
  at Xamarin.Forms.Forms/AndroidPlatformServices/&lt;&gt;c__DisplayClass17_0.&lt;StartTimer&gt;b__1 () &lt;IL 0x00006, 0x00053&gt;
  at Java.Lang.Thread/RunnableImplementor.Run () &lt;IL 0x00011, 0x00097&gt;
  at Java.Lang.IRunnableInvoker.n_Run (intptr,intptr) &lt;IL 0x0000a, 0x000a3&gt;
  at (wrapper dynamic-method) object.ba4e6bb4-0814-4b71-9867-78bee59c6f1f (intptr,intptr) &lt;IL 0x00011, 0x0003b&gt;
    --- End of managed exception stack trace ---
  java.lang.IllegalStateException: Can not perform this action after onSaveInstanceState
      at android.support.v4.app.FragmentManagerImpl.checkStateLoss(FragmentManager.java:1448)
      at android.support.v4.app.FragmentManagerImpl.enqueueAction(FragmentManager.java:1466)
      at android.support.v4.app.BackStackRecord.commitInternal(BackStackRecord.java:634)
      at android.support.v4.app.BackStackRecord.commit(BackStackRecord.java:613)
      at mono.java.lang.RunnableImplementor.n_run(Native Method)
      at mono.java.lang.RunnableImplementor.run(RunnableImplementor.java:29)
      at android.os.Handler.handleCallback(Handler.java:733)
      at android.os.Handler.dispatchMessage(Handler.java:95)
      at android.os.Looper.loop(Looper.java:146)
      at android.app.ActivityThread.main(ActivityThread.java:5603)
      at java.lang.reflect.Method.invokeNative(Native Method)
      at java.lang.reflect.Method.invoke(Method.java:515)
      at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1283)
      at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1099)
      at dalvik.system.NativeStart.main(Native Method)
  03): Shutting down VM
  hreadid=1: thread exiting with uncaught exception (group=0x41b6bc08)
  </code></pre>
  
  <p>This error occurs at points where <code>Navigation.PushAsync</code> or <code>Navigation.PushModalAsync</code> is called.</p>