记录一个非常难以定位的bug(java.lang.Illegal

2018-11-09  本文已影响0人  Jon_Snow09

java.lang.IllegalArgumentException: Invalid Transition types

项目的bugly中出现了这个异常,然而下面的报错日志完全不能帮助定位问题,经过一系列曲折的过程之后发现了问题,在这里分享给大家

这个异常只出现在4.4的手机上,是因为代码中调用了Fragment的如下方法导致的

/**
 * Sets the Transition that will be used to move Views out of the scene when the
 * fragment is removed, hidden, or detached when not popping the back stack.
 * The exiting Views will be those that are regular Views or ViewGroups that
 * have {@link ViewGroup#isTransitionGroup} return true. Typical Transitions will extend
 * {@link android.transition.Visibility} as exiting is governed by changing visibility
 * from {@link View#VISIBLE} to {@link View#INVISIBLE}. If transition is null, the views will
 * remain unaffected.
 *
 * @param transition The Transition to use to move Views out of the Scene when the Fragment
 *          is being closed not due to popping the back stack. <code>transition</code>
 *          must be an
 *          {@link android.transition.Transition android.transition.Transition} or
 *          {@link android.support.transition.Transition android.support.transition.Transition}.
 */
public void setExitTransition(@Nullable Object transition) {
    ensureAnimationInfo().mExitTransition = transition;
}

这个方法只能在api > 21的手机上调用,如果低于这个api,就会崩溃,所以调用这个方法之前要判断当前手机的api版本

上一篇下一篇

猜你喜欢

热点阅读