Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'boolean androidx.fragment.app.FragmentManager.isDestroyed()' on a null object reference
2015年的老项目,升级到androidX下,遇到的这样的问题,
找到fragment的基类 onDetach方法,注释掉下面的代码 try...catch里面的反射方法代码
@Override public void onDetach() { super.onDetach(); try { Field childFragmentManager = Fragment.class.getDeclaredField("mChildFragmentManager"); childFragmentManager.setAccessible(true); childFragmentManager.set(this, null); } catch (NoSuchFieldException e) { throw new RuntimeException(e); } catch (IllegalAccessException e) { throw new RuntimeException(e); } }