code: private static boolean isInBackStackAndroidX(final Fragment fragment) {
          final StringWriter writer = new StringWriter();
          fragment.dump("", null, new PrintWriter(writer), null);
          final String dump = writer.toString();
          return !dump.contains("mBackStackNesting=0");
      }
docs: As of version 1.0 of AndroidX - fragment.isInBackStack() is package private which leads to
  an IllegalAccessError being thrown when trying to use it.
  This method is a temporary workaround until the issue is resolved in AndroidX.