记录一个非常难以定位的bug(java.lang.IllegalArgumentException: Invalid Transition types)

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版本

©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

相关阅读更多精彩内容

  • Android 自定义View的各种姿势1 Activity的显示之ViewRootImpl详解 Activity...
    passiontim阅读 181,022评论 25赞 708
  • 用两张图告诉你,为什么你的 App 会卡顿? - Android - 掘金 Cover 有什么料? 从这篇文章中你...
    hw1212阅读 14,742评论 2赞 59
  • 对象的创建与销毁 Item 1: 使用static工厂方法,而不是构造函数创建对象:仅仅是创建对象的方法,并非Fa...
    孙小磊阅读 2,231评论 0赞 3
  • 20180608 今天早上那个被子叠得真是方正!你怎么这么厉害? 今天晚上大部分作业做完了,只剩下一份小报没做了。...
    小西爱瓜阅读 313评论 0赞 0
  • 安装 使用Mac下自带ruby的gem命令安装(这一步耗时较长): 如果gem版本太旧,可以使用如下命令升级: r...
    dpplh阅读 225评论 0赞 1

友情链接更多精彩内容