CymChad / BaseRecyclerViewAdapterHelper

BRVAH:Powerful and flexible RecyclerAdapter
http://www.recyclerview.org/
MIT License
24.32k stars 5.16k forks source link

AS4.0中,adapter使用databinding,开启混淆后出错 #3200

Open aloe20 opened 4 years ago

aloe20 commented 4 years ago

已配置混淆规则,debug环境或AS4.0之前没问题 java.lang.ClassCastException: com.chad.library.adapter.base.viewholder.BaseViewHolder cannot be cast to com.chad.library.adapter.base.viewholder.BaseDataBindingHolder at e.c.b.d.c.a.i(:14) at e.e.a.b.a.a.z(:376) at e.e.a.b.a.a.A(:382) at e.e.a.b.a.a.onBindViewHolder(:75) at androidx.recyclerview.widget.RecyclerView$g.bindViewHolder(:7172) at androidx.recyclerview.widget.RecyclerView$v.H(:6037) at androidx.recyclerview.widget.RecyclerView$v.I(:6304) at androidx.recyclerview.widget.RecyclerView$v.p(:6143) at androidx.recyclerview.widget.RecyclerView$v.o(:6139) at androidx.recyclerview.widget.LinearLayoutManager$c.d(:2314) at androidx.recyclerview.widget.LinearLayoutManager.layoutChunk(:1631) at androidx.recyclerview.widget.LinearLayoutManager.fill(:1591) at androidx.recyclerview.widget.LinearLayoutManager.onLayoutChildren(:668) at androidx.recyclerview.widget.RecyclerView.dispatchLayoutStep2(:4141) at androidx.recyclerview.widget.RecyclerView.dispatchLayout(:3853) at androidx.recyclerview.widget.RecyclerView.onLayout(:4410) at android.view.View.layout(View.java:22114) at android.view.ViewGroup.layout(ViewGroup.java:6335) at e.i.a.a.a.a.onLayout(:629) at android.view.View.layout(View.java:22114) at android.view.ViewGroup.layout(ViewGroup.java:6335) at e.g.a.a.n.b.F(:148) at e.g.a.a.n.c.l(:43) at androidx.coordinatorlayout.widget.CoordinatorLayout.onLayout(:918) at android.view.View.layout(View.java:22114) at android.view.ViewGroup.layout(ViewGroup.java:6335) at androidx.drawerlayout.widget.DrawerLayout.onLayout(:1263) at android.view.View.layout(View.java:22114) at android.view.ViewGroup.layout(ViewGroup.java:6335) at android.widget.FrameLayout.layoutChildren(FrameLayout.java:334) at android.widget.FrameLayout.onLayout(FrameLayout.java:270) at android.view.View.layout(View.java:22114) at android.view.ViewGroup.layout(ViewGroup.java:6335) at androidx.recyclerview.widget.RecyclerView$o.layoutDecoratedWithMargins(:9739) at androidx.recyclerview.widget.LinearLayoutManager.layoutChunk(:1689) at androidx.recyclerview.widget.LinearLayoutManager.fill(:1591) at androidx.recyclerview.widget.LinearLayoutManager.onLayoutChildren(:668) at androidx.recyclerview.widget.RecyclerView.dispatchLayoutStep2(:4141) at androidx.recyclerview.widget.RecyclerView.dispatchLayout(:3853) at androidx.recyclerview.widget.RecyclerView.onLayout(:4410) at android.view.View.layout(View.java:22114) at android.view.ViewGroup.layout(ViewGroup.java:6335) at androidx.viewpager2.widget.ViewPager2.onLayout(:526) at android.view.View.layout(View.java:22114) at android.view.ViewGroup.layout(ViewGroup.java:6335) at androidx.appcompat.widget.LinearLayoutCompat.A(:1649) at androidx.appcompat.widget.LinearLayoutCompat.v(:1503) at androidx.appcompat.widget.LinearLayoutCompat.onLayout(:1411) at android.view.View.layout(View.java:22114) at android.view.ViewGroup.layout(ViewGroup.java:6335) at android.widget.FrameLayout.layoutChildren(FrameLayout.java:334) at android.widget.FrameLayout.onLayout(FrameLayout.java:270) at android.view.View.layout(View.java:22114) at android.view.ViewGroup.layout(ViewGroup.java:6335) at android.widget.FrameLayout.layoutChildren(FrameLayout.java:334) at android.widget.FrameLayout.onLayout(FrameLayout.java:270) at android.view.View.layout(View.java:22114) at android.view.ViewGroup.layout(ViewGroup.java:6335) at android.widget.FrameLayout.layoutChildren(FrameLayout.java:334) at android.widget.FrameLayout.onLayout(FrameLayout.java:270) at android.view.View.layout(View.java:22114) at android.view.ViewGroup.layout(ViewGroup.java:6335) at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1839) at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1683) at android.widget.LinearLayout.onLayout(LinearLayout.java:1592) at android.view.View.layout(View.java:22114) at android.view.ViewGroup.layout(ViewGroup.java:6335)

aloe20 commented 4 years ago

java.lang.NoSuchMethodException: com.chad.library.adapter.base.viewholder.BaseDataBindingHolder. [class android.view.View] at java.lang.Class.getConstructor0(Class.java:2332) at java.lang.Class.getDeclaredConstructor(Class.java:2170) at e.e.a.b.a.a.k(:730) at e.e.a.b.a.a.l(:674) at e.e.a.b.a.a.m(:653) at e.e.a.b.a.a.B(:649) at e.e.a.b.a.a.C(:274) at e.e.a.b.a.a.onCreateViewHolder(:75) at androidx.recyclerview.widget.RecyclerView$g.createViewHolder(:7131) at androidx.recyclerview.widget.RecyclerView$v.I(:6260) at androidx.recyclerview.widget.RecyclerView$v.p(:6143) at androidx.recyclerview.widget.RecyclerView$v.o(:6139) at androidx.recyclerview.widget.LinearLayoutManager$c.d(:2314) at androidx.recyclerview.widget.LinearLayoutManager.layoutChunk(:1631) at androidx.recyclerview.widget.LinearLayoutManager.fill(:1591) at androidx.recyclerview.widget.LinearLayoutManager.onLayoutChildren(:668) at androidx.recyclerview.widget.RecyclerView.dispatchLayoutStep2(:4141) at androidx.recyclerview.widget.RecyclerView.dispatchLayout(:3853) at androidx.recyclerview.widget.RecyclerView.onLayout(:4410) at android.view.View.layout(View.java:22114) at android.view.ViewGroup.layout(ViewGroup.java:6335) at e.i.a.a.a.a.onLayout(:629) at android.view.View.layout(View.java:22114) at android.view.ViewGroup.layout(ViewGroup.java:6335) at e.g.a.a.n.b.F(:148) at e.g.a.a.n.c.l(:43) at androidx.coordinatorlayout.widget.CoordinatorLayout.onLayout(:918) at android.view.View.layout(View.java:22114) at android.view.ViewGroup.layout(ViewGroup.java:6335) at androidx.drawerlayout.widget.DrawerLayout.onLayout(:1263) at android.view.View.layout(View.java:22114) at android.view.ViewGroup.layout(ViewGroup.java:6335) at android.widget.FrameLayout.layoutChildren(FrameLayout.java:334) at android.widget.FrameLayout.onLayout(FrameLayout.java:270) at android.view.View.layout(View.java:22114) at android.view.ViewGroup.layout(ViewGroup.java:6335) at androidx.recyclerview.widget.RecyclerView$o.layoutDecoratedWithMargins(:9739) at androidx.recyclerview.widget.LinearLayoutManager.layoutChunk(:1689) at androidx.recyclerview.widget.LinearLayoutManager.fill(:1591) at androidx.recyclerview.widget.LinearLayoutManager.onLayoutChildren(:668) at androidx.recyclerview.widget.RecyclerView.dispatchLayoutStep2(:4141) at androidx.recyclerview.widget.RecyclerView.dispatchLayout(:3853) at androidx.recyclerview.widget.RecyclerView.onLayout(:4410) at android.view.View.layout(View.java:22114) at android.view.ViewGroup.layout(ViewGroup.java:6335) at androidx.viewpager2.widget.ViewPager2.onLayout(:526) at android.view.View.layout(View.java:22114) at android.view.ViewGroup.layout(ViewGroup.java:6335) at androidx.appcompat.widget.LinearLayoutCompat.A(:1649) at androidx.appcompat.widget.LinearLayoutCompat.v(:1503) at androidx.appcompat.widget.LinearLayoutCompat.onLayout(:1411) at android.view.View.layout(View.java:22114) at android.view.ViewGroup.layout(ViewGroup.java:6335) at android.widget.FrameLayout.layoutChildren(FrameLayout.java:334) at android.widget.FrameLayout.onLayout(FrameLayout.java:270) at android.view.View.layout(View.java:22114) at android.view.ViewGroup.layout(ViewGroup.java:6335) at android.widget.FrameLayout.layoutChildren(FrameLayout.java:334) at android.widget.FrameLayout.onLayout(FrameLayout.java:270) at android.view.View.layout(View.java:22114) at android.view.ViewGroup.layout(ViewGroup.java:6335) at android.widget.FrameLayout.layoutChildren(FrameLayout.java:334) at android.widget.FrameLayout.onLayout(FrameLayout.java:270) at android.view.View.layout(View.java:22114) at android.view.ViewGroup.layout(ViewGroup.java:6335) at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1839) at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1683) at android.widget.LinearLayout.onLayout(LinearLayout.java:1592) at android.view.View.layout(View.java:22114) at android.view.ViewGroup.layout(ViewGroup.java:6335) at android.widget.FrameLayout.layoutChildren(FrameLayout.java:334) at android.widget.FrameLayout.onLayout(FrameLayout.java:270) at android.view.View.layout(View.java:22114) at android.view.ViewGroup.layout(ViewGroup.java:6335) at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1839) at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1683) at android.widget.LinearLayout.onLayout(LinearLayout.java:1592) at android.view.View.layout(View.java:22114) at android.view.ViewGroup.layout(ViewGroup.java:6335) at android.widget.FrameLayout.layoutChildren(FrameLayout.java:334) at android.widget.FrameLayout.onLayout(FrameLayout.java:270) at com.android.internal.policy.DecorView.onLayout(DecorView.java:937) at android.view.View.layout(View.java:22114) at android.view.ViewGroup.layout(ViewGroup.java:6335) at android.view.ViewRootImpl.performLayout(ViewRootImpl.java:3285) at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:2785) at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1857) at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:8089) at android.view.Choreographer$CallbackRecord.run(Choreographer.java:1057) at android.view.Choreographer.doCallbacks(Choreographer.java:875) at android.view.Choreographer.doFrame(Choreographer.java:776) at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:1042) at android.os.Handler.handleCallback(Handler.java:888) at android.os.Handler.dispatchMessage(Handler.java:100) at android.os.Looper.loop(Looper.java:213) at android.app.ActivityThread.main(ActivityThread.java:8178) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:513) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1101)

liangsaifei commented 4 years ago

附议,一样的错。

Linmuge commented 4 years ago

解决了没

erichyx commented 4 years ago

一样的错误。

wyasher commented 4 years ago

-keep class com.chad.library.adapter.base.viewholder.BaseDataBindingHolder {*;}

Cedar-byte commented 3 years ago

没有用,加了还是报错,只能用老版本的写法,唉

TxcA commented 3 years ago

没用DataBinding, 但我这边用ViewBinding出现过类似的错误,看了下源码,是反射的时候报错了。 报错前:

class ViewBindingHolder<VB : ViewBinding>(val viewBinding: VB ) : BaseViewHolder(viewBinding.root)

修改后:

class ViewBindingHolder<VB : ViewBinding>(view: View) : BaseViewHolder(view) {

    lateinit var viewBinding: VB

    constructor(viewBinding: VB) : this(viewBinding.root) {
        this.viewBinding = viewBinding
    }
}

翻了下,报错在BaseQuickAdapter 中 722行 createBaseGenericKInstance ,的方法里报错。大概报错意思是找不到 xxxViewHolder(我这边就是ViewBindingHolder)的主构造(view:View),没用BaseDataBindingHolder,所以只能给个参考。

KAICW commented 3 years ago

一样的错误。