无法检索removeGhost方法 [英] Failed to retrieve removeGhost method

本文介绍了无法检索removeGhost方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我要在我的应用中放置Android导航组件.
某些过渡效果很好,但是对此我有一个错误.来自片段A的过渡视图保留在新片段(B)上并隐藏一些元素.而且,当我滚动片段时,视图不会随之滚动.这是我得到的错误:

I'm putting in place the Android Navigation Component in my app.
Some transitions work fine, but for this one I have an error. The transition view, from fragment A, stay on the new fragment (B) and hide some elements. Moreover, when I scroll in the fragment, the view don't scroll with it. This is the error I get:

W/t.qoqa.ui.debu: Accessing hidden method Landroid/view/GhostView;->removeGhost(Landroid/view/View;)V (greylist-max-p, reflection, denied)
I/GhostViewApi21: Failed to retrieve removeGhost method
    java.lang.NoSuchMethodException: android.view.GhostView.removeGhost [class android.view.View]

我从片段A的RecyclerView开始,在其中单击时,我设置了唯一的过渡名称.
然后,我将该名称作为参数使用SafeArgs以及FragmentNavigatorExtras中的视图进行传递.

I start from a RecyclerView in fragment A, where on click I set a unique the transition name.
Then, I pass this name as an argument using SafeArgs along with the view in FragmentNavigatorExtras.

在片段B中,我延迟了onCreate的转换: postponeEnterTransition()并设置过渡类型:

In fragment B, I delay the transition in onCreate: postponeEnterTransition() and set the transition type :

transition = TransitionSet().apply {
    addTransition(ChangeTransform())
    addTransition(ChangeBounds())
    startDelay = 150
}
sharedElementEnterTransition = transition
sharedElementReturnTransition = transition

我在onViewCreated中设置了名称: ViewCompat.setTransitionName(product_image,args.imageTransitionName)

I set the name in onViewCreated: ViewCompat.setTransitionName(product_image, args.imageTransitionName)

最后,当准备好显示图像时,滑行监听器开始过渡:

And finally, a Glide Listener start the transition when the image is ready to be shown:

listener = object: RequestListener<Drawable> {
    override fun onLoadFailed(
        e: GlideException?,
        model: Any?,
        target: Target<Drawable>?,
        isFirstResource: Boolean
    ): Boolean {
        startPostponedEnterTransition()
        return false
    }

    override fun onResourceReady(
        resource: Drawable?,
        model: Any?,
        target: Target<Drawable>?,
        dataSource: DataSource?,
        isFirstResource: Boolean
    ): Boolean {
        startPostponedEnterTransition()
        return false
    }
}

返回转换也不起作用.
我只使用 androidx.transition.* 元素

And the return transition does not work either.
I'm using only androidx.transition.* elements

预先感谢您的帮助

推荐答案

我在Google的Transitions库中工作.此问题意味着您已将Android 10(Q)设置为targetSdkVersion,并使用了过时的过渡库版本.较旧的版本使用反射来实现Android Framework的私有方法,该方法现在从Q开始受到限制(当您将其指定为targetSdk而不是compileAdk时).较新的版本不再使用反射.要解决此问题,您需要将过渡库版本更新为至少1.2.0. https://developer.android.com/jetpack/androidx/releases/transition#1.2.0

I work in Google on Transitions library. This issue means you have set Android 10(Q) as a targetSdkVersion and using an outdated version of transition library. Older version was using reflection to reach the private methods from Android Framework which is now restricted starting from Q(when you specify it as targetSdk, not compileAdk). Newer version is not using reflection anymore. To fix this you need to update the transition library version to at least 1.2.0 https://developer.android.com/jetpack/androidx/releases/transition#1.2.0

这篇关于无法检索removeGhost方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆