带有空共享元素的Conent Transition NPE [英] Conent Transition NPE with empty shared elements
问题描述
我正在将内容过渡添加到一个非常大的应用程序中,并且在大多数情况下,我没有任何共享元素,但仍想使用过渡动画.我已将问题归结为以下代码行:
I am adding content transitions to a pretty large app and in most cases I do not have any shared elements but still want to use the transition animations. I have tracked the problem down to this line of code:
ActivityOptionsCompat.makeSceneTransitionAnimation(activity, ????);
我尝试将Pair array设置为null或一个空数组,并且尝试将其遗漏.一切都会导致以下错误:
I have tried setting Pair array to null or an empty array and I have tried just leaving it out. Everything results in the following error:
java.lang.NullPointerException: Attempt to invoke virtual method 'void android.view.ViewRootImpl.setPausedForTransition(boolean)' on a null object reference
但是,我仅在Android 6.0+上出现此错误,它在任何版本的Android 5上都可以正常工作.我是否尝试以错误的方式执行此操作?
However, I only get this error on Android 6.0+, it works fine on any version of Android 5. Am I trying to do this the wrong way?
推荐答案
I did a bunch of digging in the source code and it looks like this is caused by a missed null pointer check that got fixed for Nougat.
不幸的是,我不知道如何在6.x上解决它.我想您可以添加6.x try
/catch
,如果它确实在崩溃方面使您丧命,但是这可能还会捕获许多您可能不希望看到的其他内容.
I've got no clue how to work around it on 6.x though, unfortunately. I suppose you could add a 6.x try
/catch
if it's really killing you in terms of crashes, but that may also catch a bunch of other stuff you may not want it to.
这篇关于带有空共享元素的Conent Transition NPE的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!