-
Notifications
You must be signed in to change notification settings - Fork 2.1k
java.lang.NullPointerException: Attempt to invoke virtual method 'int me.yokeyword.fragmentation.anim.FragmentAnimator.getEnter()' on a null object reference #825
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
@nicai1900 进程被杀后会做恢复操作,恢复代码在这里 1、复现的机型是? |
1、复现的机型是? 与机型无关,6.0以上需要动态权限就会 2、和哪个Demo无关,问题是必现的。在系统权限管理界面,动态开关APP的权限,进程被干掉,重新打开APP时,savedInstanceState 不为空,但是从savedInstanceState反序列化回来的mFragmentAnimator是空的 因此崩溃了。 SupportFragmentDelegate.java:108
public void onCreate(@Nullable Bundle savedInstanceState) {
// 重新打开APP时,savedInstanceState != null
if (savedInstanceState == null) {
getFragmentAnimator();
} else {
mSaveInstanceState = savedInstanceState;
// 这里反序列化回来的结果是null
mFragmentAnimator = savedInstanceState.getParcelable(TransactionDelegate.FRAGMENTATION_STATE_SAVE_ANIMATOR);
mIsHidden = savedInstanceState.getBoolean(TransactionDelegate.FRAGMENTATION_STATE_SAVE_IS_HIDDEN);
mContainerId = savedInstanceState.getInt(TransactionDelegate.FRAGMENTATION_ARG_CONTAINER);
// RootFragment
if (mRootStatus != STATUS_UN_ROOT) {
FragmentationMagician.reorderIndices(mFragment.getFragmentManager());
}
}
} |
@nicai1900 让我很困扰的是: 确实做了恢复操作, 而且我一直无法复现该问题 (即使按你的场景去尝试) 为了更好的排查该问题,可否留个联系方式QQ / 微信,我们进一步交流该问题? |
@YoKeyword 我的微信号 zhengjie1900 |
这个问题解决了吗 |
这个问题确实跟机型无关,长时间后台再进到app里面就会出现这样的问题。应该是 mFragmentAnimator为空了, |
@YoKeyword 问题解决了,我自己的错 自己实现了ISupportFragment 接口,漏了复写下面的接口了,因此导致没有保存mFragmentAnimator的数据。 override fun onSaveInstanceState(outState: Bundle) {
super.onSaveInstanceState(outState)
delegate.onSaveInstanceState(outState)
} |
我也在实现ISupportFragment 的接口中重写了那个onSaveInstanceState()方法,我自己怎么测都不会出现这个bug,但是bug收集工具收集了很多这个崩溃信息, 根据用户反馈就是长时间后台再进入就会出现这个问题。 |
@z1060932884 v4包更新到27.1.1试试。 |
@z1060932884 楼上2位同学一个同学是忘记在Fragment里 所有检查Activity和Fragment的 |
找到原因了 ,进程杀死时onSaveInstanceState方法在执行次数比onCreate方法执行次数少,然后查看自己写的代码,去掉了一个Fragment加载Fragment的界面就好了。 @YoKeyword @foolchen |
Uh oh!
There was an error while loading. Please reload this page.
#问题出现概率:必现
复现方法
APP启动后,到系统权限设置界面去关闭APP的某个权限,会导致APP进程退出,重新打开APP,就会崩溃
#手机系统:6.0以上
Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'int me.yokeyword.fragmentation.anim.FragmentAnimator.getEnter()' on a null object reference at me.yokeyword.fragmentation.helper.internal.AnimatorHelper.initEnterAnim(AnimatorHelper.java:63) at me.yokeyword.fragmentation.helper.internal.AnimatorHelper.notifyChanged(AnimatorHelper.java:29) at me.yokeyword.fragmentation.helper.internal.AnimatorHelper.<init>(AnimatorHelper.java:24) at me.yokeyword.fragmentation.SupportFragmentDelegate.onCreate(SupportFragmentDelegate.java:117)
In addition, we do not accept issues unrelated to Fragmentation.
The text was updated successfully, but these errors were encountered: