title: Android app error android.view.InflateException. With Jetpack Navigation Component
body: <p>trying to make app that use Naviagtion Components with two simple screens managed with Navigation Graph, one of witch is:</p>
  <p>MainFragment:</p>
  <pre><code>public class MainFragment extends Fragment {
  
  private MainViewModel mViewModel;
  
  public static MainFragment newInstance() {
      return new MainFragment();
  }
  
  @Nullable
  @Override
  public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container,
                           @Nullable Bundle savedInstanceState) {
      return inflater.inflate(R.layout.main_fragment, container, false);
  }
  
  @Override
  public void onActivityCreated(@Nullable Bundle savedInstanceState) {
      super.onActivityCreated(savedInstanceState);
      mViewModel = new ViewModelProvider(this).get(MainViewModel.class);
  
      Button button = getView().findViewById(R.id.button);
  
      button.setOnClickListener(Navigation.createNavigateOnClickListener(R.id.mainToSecond,null));
  
      // TODO: Use the ViewModel
  }
  </code></pre>
  <p>}</p>
  <p>And 2nd screen:</p>
  <pre><code>public class SecondFragment extends Fragment {
  
  
  public interface OnFragmentInteractionListener {
      // TODO: Update argument type and name
      void onFragmentInteraction(Uri uri);
  }
  
  // TODO: Rename parameter arguments, choose names that match
  // the fragment initialization parameters, e.g. ARG_ITEM_NUMBER
  private static final String ARG_PARAM1 = &quot;param1&quot;;
  private static final String ARG_PARAM2 = &quot;param2&quot;;
  
  // TODO: Rename and change types of parameters
  private String mParam1;
  private String mParam2;
  
  
  public SecondFragment() {
      // Required empty public constructor
  }
  
  /**
   * Use this factory method to create a new instance of
   * this fragment using the provided parameters.
   *
   * @param param1 Parameter 1.
   * @param param2 Parameter 2.
   * @return A new instance of fragment SecondFragment.
   */
  // TODO: Rename and change types and number of parameters
  public static SecondFragment newInstance(String param1, String param2) {
      SecondFragment fragment = new SecondFragment();
      Bundle args = new Bundle();
      args.putString(ARG_PARAM1, param1);
      args.putString(ARG_PARAM2, param2);
      fragment.setArguments(args);
      return fragment;
  }
  
  @Override
  public void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      if (getArguments() != null) {
          mParam1 = getArguments().getString(ARG_PARAM1);
          mParam2 = getArguments().getString(ARG_PARAM2);
      }
  }
  
  @Override
  public View onCreateView(LayoutInflater inflater, ViewGroup container,
                           Bundle savedInstanceState) {
      // Inflate the layout for this fragment
      return inflater.inflate(R.layout.fragment_second, container, false);
  }
  </code></pre>
  <p>}</p>
  <p>My &quot;Navigation Host&quot; is  MainActivity class:</p>
  <pre><code>public class MainActivity extends AppCompatActivity implements
      SecondFragment.OnFragmentInteractionListener {
  
  @Override
  protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.main_activity);
  }
  @Override
  public void onFragmentInteraction(Uri uri){}}
  </code></pre>
  <p>While running up on emulator, Gradle showing no erros but app doesn't launch.
  Here's error that I've got.</p>
  <pre><code> java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.navigationdemo/com.example.navigationdemo.ui.main.MainActivity}: android.view.InflateException: Binary XML file line #10
  </code></pre>
  <p>main_activity XML  code:</p>
  <pre><code>&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;
   &lt;FrameLayout xmlns:android=&quot;http://schemas.android.com/apk/res/android&quot;
  xmlns:app=&quot;http://schemas.android.com/apk/res-auto&quot;
  xmlns:tools=&quot;http://schemas.android.com/tools&quot;
  android:id=&quot;@+id/container&quot;
  android:layout_width=&quot;match_parent&quot;
  android:layout_height=&quot;match_parent&quot;
  tools:context=&quot;.ui.main.MainActivity&quot; &gt;
  
  &lt;fragment
      android:id=&quot;@+id/demo_nav_host_fragment&quot;
      android:name=&quot;androidx.navigation.fragment.NavHostFragment&quot;
      android:layout_width=&quot;match_parent&quot;
      android:layout_height=&quot;match_parent&quot;
      app:defaultNavHost=&quot;true&quot;
      app:navGraph=&quot;@navigation/navigation_graph&quot;/&gt;
  </code></pre>
  
  <p>Full exception:</p>
  <pre><code>  Process: com.example.navigationdemo, PID: 13360
  java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.navigationdemo/com.example.navigationdemo.ui.main.MainActivity}: android.view.InflateException: Binary XML file line #11 in com.example.navigationdemo:layout/main_activity: Binary XML file line #11 in com.example.navigationdemo:layout/main_activity: Error inflating class fragment
      at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3270)
      at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3409)
      at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:83)
      at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:135)
      at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:95)
      at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2016)
      at android.os.Handler.dispatchMessage(Handler.java:107)
      at android.os.Looper.loop(Looper.java:214)
      at android.app.ActivityThread.main(ActivityThread.java:7356)
      at java.lang.reflect.Method.invoke(Native Method)
      at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:492)
      at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:930)
   Caused by: android.view.InflateException: Binary XML file line #11 in com.example.navigationdemo:layout/main_activity: Binary XML file line #11 in com.example.navigationdemo:layout/main_activity: Error inflating class fragment
   Caused by: android.view.InflateException: Binary XML file line #11 in com.example.navigationdemo:layout/main_activity: Error inflating class fragment
   Caused by: java.lang.IllegalStateException: Fragment class was not set
      at androidx.navigation.fragment.FragmentNavigator$Destination.getClassName(FragmentNavigator.java:322)
      at androidx.navigation.fragment.FragmentNavigator.navigate(FragmentNavigator.java:158)
      at androidx.navigation.fragment.FragmentNavigator.navigate(FragmentNavigator.java:58)
      at androidx.navigation.NavGraphNavigator.navigate(NavGraphNavigator.java:71)
      at androidx.navigation.NavGraphNavigator.navigate(NavGraphNavigator.java:28)
      at androidx.navigation.NavController.navigate(NavController.java:1049)
      at androidx.navigation.NavController.onGraphCreated(NavController.java:633)
      at androidx.navigation.NavController.setGraph(NavController.java:586)
      at androidx.navigation.NavController.setGraph(NavController.java:551)
      at androidx.navigation.NavController.setGraph(NavController.java:533)
      at androidx.navigation.fragment.NavHostFragment.onCreate(NavHostFragment.java:238)
      at androidx.fragment.app.Fragment.performCreate(Fragment.java:2684)
      at androidx.fragment.app.FragmentStateManager.create(FragmentStateManager.java:280)
      at androidx.fragment.app.FragmentManager.moveToState(FragmentManager.java:1175)
      at androidx.fragment.app.FragmentManager.moveToState(FragmentManager.java:1356)
      at androidx.fragment.app.FragmentLayoutInflaterFactory.onCreateView(FragmentLayoutInflaterFactory.java:109)
      at androidx.fragment.app.FragmentController.onCreateView(FragmentController.java:135)
      at androidx.fragment.app.FragmentActivity.dispatchFragmentsOnCreateView(FragmentActivity.java:356)
      at androidx.fragment.app.FragmentActivity.onCreateView(FragmentActivity.java:335)
      at android.view.LayoutInflater.tryCreateView(LayoutInflater.java:1069)
      at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:997)
      at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:961)
      at android.view.LayoutInflater.rInflate(LayoutInflater.java:1123)
      at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:1084)
      at android.view.LayoutInflater.inflate(LayoutInflater.java:682)
      at android.view.LayoutInflater.inflate(LayoutInflater.java:534)
      at android.view.LayoutInflater.inflate(LayoutInflater.java:481)
      at androidx.appcompat.app.AppCompatDelegateImpl.setContentView(AppCompatDelegateImpl.java:696)
  E/AndroidRuntime:     at androidx.appcompat.app.AppCompatActivity.setContentView(AppCompatActivity.java:170)
      at com.example.navigationdemo.ui.main.MainActivity.onCreate(MainActivity.java:15)
      at android.app.Activity.performCreate(Activity.java:7802)
      at android.app.Activity.performCreate(Activity.java:7791)
      at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1299)
      at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3245)
      at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3409)
      at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:83)
      at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:135)
      at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:95)
      at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2016)
      at android.os.Handler.dispatchMessage(Handler.java:107)
      at android.os.Looper.loop(Looper.java:214)
      at android.app.ActivityThread.main(ActivityThread.java:7356)
      at java.lang.reflect.Method.invoke(Native Method)
      at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:492)
      at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:930)
  </code></pre>
  <p>Full exception when using</p>
  <blockquote>
  <p>&lt;androidx.fragment.app.FragmentContainerView</p>
  </blockquote>
  <pre><code> Process: com.example.navigationdemo, PID: 12977
  java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.navigationdemo/com.example.navigationdemo.ui.main.MainActivity}: android.view.InflateException: Binary XML file line #11 in com.example.navigationdemo:layout/main_activity: Binary XML file line #11 in com.example.navigationdemo:layout/main_activity: Error inflating class androidx.fragment.app.FragmentContainerView
      at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3270)
      at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3409)
      at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:83)
      at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:135)
      at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:95)
      at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2016)
      at android.os.Handler.dispatchMessage(Handler.java:107)
      at android.os.Looper.loop(Looper.java:214)
      at android.app.ActivityThread.main(ActivityThread.java:7356)
      at java.lang.reflect.Method.invoke(Native Method)
      at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:492)
      at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:930)
   Caused by: android.view.InflateException: Binary XML file line #11 in com.example.navigationdemo:layout/main_activity: Binary XML file line #11 in com.example.navigationdemo:layout/main_activity: Error inflating class androidx.fragment.app.FragmentContainerView
   Caused by: android.view.InflateException: Binary XML file line #11 in com.example.navigationdemo:layout/main_activity: Error inflating class androidx.fragment.app.FragmentContainerView
   Caused by: java.lang.IllegalStateException: Fragment class was not set
      at androidx.navigation.fragment.FragmentNavigator$Destination.getClassName(FragmentNavigator.java:322)
      at androidx.navigation.fragment.FragmentNavigator.navigate(FragmentNavigator.java:158)
      at androidx.navigation.fragment.FragmentNavigator.navigate(FragmentNavigator.java:58)
      at androidx.navigation.NavGraphNavigator.navigate(NavGraphNavigator.java:71)
      at androidx.navigation.NavGraphNavigator.navigate(NavGraphNavigator.java:28)
      at androidx.navigation.NavController.navigate(NavController.java:1049)
      at androidx.navigation.NavController.onGraphCreated(NavController.java:633)
      at androidx.navigation.NavController.setGraph(NavController.java:586)
      at androidx.navigation.NavController.setGraph(NavController.java:551)
      at androidx.navigation.NavController.setGraph(NavController.java:533)
      at androidx.navigation.fragment.NavHostFragment.onCreate(NavHostFragment.java:238)
      at androidx.fragment.app.Fragment.performCreate(Fragment.java:2684)
      at androidx.fragment.app.FragmentStateManager.create(FragmentStateManager.java:280)
      at androidx.fragment.app.FragmentManager.moveToState(FragmentManager.java:1175)
      at androidx.fragment.app.FragmentManager.addAddedFragments(FragmentManager.java:2224)
      at androidx.fragment.app.FragmentManager.executeOpsTogether(FragmentManager.java:1997)
      at androidx.fragment.app.FragmentManager.removeRedundantOperationsAndExecute(FragmentManager.java:1953)
      at androidx.fragment.app.FragmentManager.execSingleAction(FragmentManager.java:1818)
      at androidx.fragment.app.BackStackRecord.commitNowAllowingStateLoss(BackStackRecord.java:303)
      at androidx.fragment.app.FragmentContainerView.&lt;init&gt;(FragmentContainerView.java:166)
      at androidx.fragment.app.FragmentLayoutInflaterFactory.onCreateView(FragmentLayoutInflaterFactory.java:51)
      at androidx.fragment.app.FragmentController.onCreateView(FragmentController.java:135)
      at androidx.fragment.app.FragmentActivity.dispatchFragmentsOnCreateView(FragmentActivity.java:356)
      at androidx.fragment.app.FragmentActivity.onCreateView(FragmentActivity.java:335)
      at android.view.LayoutInflater.tryCreateView(LayoutInflater.java:1069)
  2020-10-28 12:23:26.527 12977-12977/com.example.navigationdemo E/AndroidRuntime:     at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:997)
      at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:961)
      at android.view.LayoutInflater.rInflate(LayoutInflater.java:1123)
      at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:1084)
      at android.view.LayoutInflater.inflate(LayoutInflater.java:682)
      at android.view.LayoutInflater.inflate(LayoutInflater.java:534)
      at android.view.LayoutInflater.inflate(LayoutInflater.java:481)
      at androidx.appcompat.app.AppCompatDelegateImpl.setContentView(AppCompatDelegateImpl.java:696)
      at androidx.appcompat.app.AppCompatActivity.setContentView(AppCompatActivity.java:170)
      at com.example.navigationdemo.ui.main.MainActivity.onCreate(MainActivity.java:15)
      at android.app.Activity.performCreate(Activity.java:7802)
      at android.app.Activity.performCreate(Activity.java:7791)
      at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1299)
      at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3245)
      at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3409)
      at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:83)
      at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:135)
      at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:95)
      at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2016)
      at android.os.Handler.dispatchMessage(Handler.java:107)
      at android.os.Looper.loop(Looper.java:214)
      at android.app.ActivityThread.main(ActivityThread.java:7356)
      at java.lang.reflect.Method.invoke(Native Method)
      at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:492)
      at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:930)
  </code></pre>