title: NavHostFragment not accessible from XML
body: <p>I wanted to try new Navigation library. After following <a href="https://developer.android.com/topic/libraries/architecture/navigation/navigation-implementing" rel="noreferrer">this guideline</a> I experienced error at runtime:</p>
  
  <pre><code>Caused by: android.view.InflateException: Binary XML file line #11: Binary XML file line #11: Error inflating class fragment
  Caused by: android.view.InflateException: Binary XML file line #11: Error inflating class fragment
  Caused by: android.app.Fragment$InstantiationException: Unable to instantiate fragment androidx.navigation.fragment.NavHostFragment: make sure class name exists, is public, and has an empty constructor that is public
  </code></pre>
  
  <p>in resource file <code>activity_home.xml</code>. This file is very simple:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;FrameLayout
      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/container"
      android:layout_width="match_parent"
      android:layout_height="match_parent"
      tools:context=".ui.home.HomeActivity"&gt;
  
      &lt;fragment
          android:id="@+id/fragment_navigation_host"
          android:name="androidx.navigation.fragment.NavHostFragment"
          app:defaultNavHost="true"
          app:navGraph="@navigation/navigation_home" /&gt;
  
  &lt;/FrameLayout&gt;
  </code></pre>
  
  <p>I looked at the source code of <code>NavHostFragment</code> and I noticed that it uses <code>android.support.v4.app.Fragment</code> while whole my application uses <code>androidx.fragment.app.Fragment</code>. </p>
  
  <p>I'm not convinced that this is the issue, but I'm including some of my dependencies below:</p>
  
  <pre><code>// AndroidX
  implementation     "androidx.appcompat:appcompat:$appCompatVersion"
  implementation     "androidx.constraintlayout:constraintlayout:$constraintLayoutVersion"
  implementation     "androidx.lifecycle:lifecycle-extensions:$lifecycleVersion"
  implementation     "androidx.recyclerview:recyclerview:$recyclerViewVersion"
  implementation     "androidx.room:room-runtime:$roomVersion"
  implementation     "androidx.room:room-rxjava2:$roomVersion"
  
  kapt               "androidx.room:room-compiler:$roomVersion"
  
  // Navigation
  implementation     "android.arch.navigation:navigation-fragment-ktx:$navigationVersion"
  implementation     "android.arch.navigation:navigation-ui-ktx:$navigationVersion"
  </code></pre>
  
  <p>As you can see I'm using libraries from AndroidX except Navigation, because probably it's not migrated yet. The only place on Google where I can find <code>androidx.navigation</code> is <a href="https://developer.android.com/jetpack/docs/getting-started" rel="noreferrer">here</a>. Unfortunately Gradle is unable to download it.</p>
  
  <p><strong>Edit</strong></p>
  
  <p>I also have jetifier tool enabled inside my <code>gradle.properties</code>.</p>
  
  <pre><code>android.enableJetifier=true
  android.useAndroidX=true
  </code></pre>
  
  <p><strong>Update</strong></p>
  
  <p>It is fixed in Android Studio 3.2 Canary 17 as mentioned in <a href="https://stackoverflow.com/a/50385411/4386668">this answer</a>. Don't forget to invalidate cache and restart in order to remove warnings in code.</p>