title: java.lang.IllegalStateException:The specified child already has a parent. You must call removeView() on the child's parent first
body: <p>Making small tasker for android in kotlin language I bumped into an issue with navigation.
  When I press "add" button on the main screen (ListFragment) i want my app to navigate to another screen(CreateTaskFragment) where user will be able to create a task, but instead, android studio give me such a stack trace:</p>
  
  <pre><code>E/AndroidRuntime: FATAL EXCEPTION: main
      Process: com.oleksii.routinetracker, PID: 21231
      java.lang.IllegalStateException: The specified child already has a parent. You must call removeView() on the child's parent first.
          at android.view.ViewGroup.addViewInner(ViewGroup.java:5034)
          at android.view.ViewGroup.addView(ViewGroup.java:4865)
          at android.view.ViewGroup.addView(ViewGroup.java:4805)
          at android.view.ViewGroup.addView(ViewGroup.java:4778)
          at androidx.fragment.app.FragmentManagerImpl.moveToState(FragmentManagerImpl.java:887)
          at androidx.fragment.app.FragmentManagerImpl.addAddedFragments(FragmentManagerImpl.java:2100)
          at androidx.fragment.app.FragmentManagerImpl.executeOpsTogether(FragmentManagerImpl.java:1874)
          at androidx.fragment.app.FragmentManagerImpl.removeRedundantOperationsAndExecute(FragmentManagerImpl.java:1830)
          at androidx.fragment.app.FragmentManagerImpl.execPendingActions(FragmentManagerImpl.java:1727)
          at androidx.fragment.app.FragmentManagerImpl$2.run(FragmentManagerImpl.java:150)
          at android.os.Handler.handleCallback(Handler.java:873)
          at android.os.Handler.dispatchMessage(Handler.java:99)
          at android.os.Looper.loop(Looper.java:193)
          at android.app.ActivityThread.main(ActivityThread.java:6669)
          at java.lang.reflect.Method.invoke(Native Method)
          at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
          at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)
  </code></pre>
  
  <p>What should i do to solve this problem? Here is my code:</p>
  
  <pre><code>class MainActivity : AppCompatActivity() {
  
      override fun onCreate(savedInstanceState: Bundle?) {
          super.onCreate(savedInstanceState)
          setContentView(R.layout.activity_main)
      }
  }
  
  </code></pre>
  
  <pre><code>class ListFragment : Fragment() {
  
      private lateinit var viewModel: ListViewModel
      private lateinit var binding: FragmentListBinding
  
      override fun onCreateView(
          inflater: LayoutInflater, container: ViewGroup?,
          savedInstanceState: Bundle?): View? {
  
          viewModel = ViewModelProviders.of(this).get(ListViewModel::class.java)
          binding = DataBindingUtil.inflate(inflater, R.layout.fragment_list, container, false)
  
          binding.addButton.setOnClickListener {
              findNavController().navigate(R.id.action_listFragment_to_createTaskFragment)
          }
  
          return binding.root
      }
  }
  </code></pre>
  
  <pre><code>class CreateTaskFragment : Fragment() {
  
      private lateinit var viewModel: CreateTaskViewModel
      private lateinit var binding: FragmentCreateTaskBinding
  
      override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?,
          savedInstanceState: Bundle?): View? {
  
          viewModel = ViewModelProviders.of(this).get(CreateTaskViewModel::class.java)
          binding = DataBindingUtil.inflate(inflater, R.layout.fragment_create_task, container, true)
  
          binding.button.setOnClickListener {view: View -&gt;
              view.findNavController().navigate(R.id.action_createTaskFragment_to_listFragment)
          }
  
          return binding.root
      }
  
  
  }
  </code></pre>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;navigation 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:id="@+id/navigation"
      app:startDestination="@id/listFragment"&gt;
  
      &lt;fragment
          android:id="@+id/listFragment"
          android:name="com.oleksii.routinetracker.list.ListFragment"
          android:label="fragment_list"
          tools:layout="@layout/fragment_list" &gt;
          &lt;action
              android:id="@+id/action_listFragment_to_createTaskFragment"
              app:destination="@id/createTaskFragment"
              app:launchSingleTop="true"/&gt;
      &lt;/fragment&gt;
      &lt;fragment
          android:id="@+id/createTaskFragment"
          android:name="com.oleksii.routinetracker.createtask.CreateTaskFragment"
          android:label="fragment_create_task"
          tools:layout="@layout/fragment_create_task"&gt;
          &lt;action
              android:id="@+id/action_createTaskFragment_to_listFragment"
              app:destination="@id/listFragment" /&gt;
      &lt;/fragment&gt;
  &lt;/navigation&gt;
  </code></pre>
  
  <p>And also some xml's files:</p>
  
  <pre><code>&lt;!-- fragment_list --&gt;
  &lt;layout 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"
      tools:context="com.oleksii.routinetracker.list.ListFragment"&gt;
  
      &lt;androidx.constraintlayout.widget.ConstraintLayout
          android:id="@+id/list_layout"
          android:layout_width="match_parent"
          android:layout_height="match_parent"&gt;
  
          &lt;androidx.core.widget.NestedScrollView
              android:id="@+id/tasks_scroll"
              android:layout_width="match_parent"
              android:layout_height="wrap_content"
              app:layout_constraintEnd_toEndOf="parent"
              app:layout_constraintStart_toStartOf="parent"
              app:layout_constraintTop_toTopOf="parent"&gt;
  
              &lt;LinearLayout
                  android:id="@+id/tasks_lin"
                  style="@style/tasks"
                  android:layout_width="match_parent"
                  android:layout_height="wrap_content"
                  android:orientation="vertical"&gt;
  
                  &lt;TextView
                      android:layout_width="match_parent"
                      android:layout_height="match_parent"
                      android:paddingTop="@dimen/small_padding"
                      android:fontFamily="@font/roboto"
                      android:text="@string/my_tasks"
                      android:textColor="@color/colorBlack"
                      android:textSize="48sp" /&gt;
              &lt;/LinearLayout&gt;
          &lt;/androidx.core.widget.NestedScrollView&gt;
  
          &lt;androidx.constraintlayout.widget.Guideline
              android:id="@+id/guideline"
              android:layout_width="wrap_content"
              android:layout_height="wrap_content"
              android:orientation="horizontal"
              app:layout_constraintGuide_end="96dp" /&gt;
  
          &lt;Button
              android:id="@+id/add_button"
              android:layout_width="wrap_content"
              android:layout_height="wrap_content"
              android:text="@string/add"
              android:textColor="@color/colorBlue500"
              android:textSize="18sp"
              android:background="@drawable/custom_button"
              app:layout_constraintBottom_toBottomOf="parent"
              app:layout_constraintEnd_toEndOf="parent"
              app:layout_constraintStart_toStartOf="parent"
              app:layout_constraintTop_toTopOf="@+id/guideline" /&gt;
      &lt;/androidx.constraintlayout.widget.ConstraintLayout&gt;
  &lt;/layout&gt;
  </code></pre>
  
  <pre><code>&lt;!-- activity_main --&gt;
  &lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;androidx.constraintlayout.widget.ConstraintLayout
      xmlns:android="http://schemas.android.com/apk/res/android"
      xmlns:tools="http://schemas.android.com/tools"
      xmlns:app="http://schemas.android.com/apk/res-auto"
      android:layout_width="match_parent"
      android:layout_height="match_parent"
      tools:context=".MainActivity"&gt;
  
      &lt;fragment
          android:id="@+id/myNavHostFragment"
          android:name="androidx.navigation.fragment.NavHostFragment"
          android:layout_width="match_parent"
          android:layout_height="match_parent"
          app:navGraph="@navigation/navigation"
          app:defaultNavHost="true" /&gt;
  &lt;/androidx.constraintlayout.widget.ConstraintLayout&gt;
  </code></pre>
  
  <p>Thank you in advance!</p>