java.lang.NoSuchMethodError: No static method onPullDistance(Landroid/widget/EdgeEffect;FF)F in clas

记录一下学习中最近偶遇两次这个错误:

java.lang.NoSuchMethodError: No static method onPullDistance(Landroid/widget/EdgeEffect;FF)F in class Landroidx/core/widget/EdgeEffectCompat; or its super classes (declaration of 'androidx.core.widget.EdgeEffectCompat' appears in /data/app/com.jiangxue.heartview-sDxXREwWLDMCpWawbYlahw==/base.apk)

debug一下最近问题定位到了这里

public static float onPullDistance(
            @NonNull EdgeEffect edgeEffect,
            float deltaDistance,
            float displacement
    ) {
        if (BuildCompat.isAtLeastS()) {
            return Api31Impl.onPullDistance(edgeEffect, deltaDistance, displacement);
        }
        onPull(edgeEffect, deltaDistance, displacement);
        return deltaDistance;
    }

为什么突然间滑动边缘时不设置边缘效果会报错,首先检查一下对应版本问题

看一下我的布局

<?xml version="1.0" encoding="utf-8"?>
<layout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools">

    <data>
      <!--  <import type="com.jiangxue.heartview.R" />-->
        <variable
            name="viewModel"
            type="com.jiangxue.heartview.ui.main.fragment.FateViewModel" />



    </data>


    <androidx.recyclerview.widget.RecyclerView
            android:id="@+id/rv_topic"
            android:orientation="horizontal"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"/>
</layout>

试着布局修改后正常了:

<?xml version="1.0" encoding="utf-8"?>
<layout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools">

    <data>
 
        <variable
            name="viewModel"
            type="com.jiangxue.heartview.ui.main.fragment.FateViewModel" />

    </data>


    <androidx.recyclerview.widget.RecyclerView
            android:id="@+id/rv_topic"
            android:overScrollMode="never"
            android:scrollbars="none"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"/>
</layout>

这行代码:试着禁掉边缘效果

android:overScrollMode="never" 可以设置滑动到边缘时的光晕效果
   android:overScrollMode=""
   有三个属性
   never:去掉光晕效果
   always:设置总是出现光晕效果
   ifContentScrolls:设置此模式,如果recycleview里面的内容可以滑动,那么滑到边界后继续滑动会出现弧形光晕;如果recycleview里面的内容不可以滑动,那么滑到边界后继续滑动不会出现弧形光晕

试着降低版本

implementation 'androidx.recyclerview:recyclerview:1.3.0'

implementation 'androidx.recyclerview:recyclerview:1.1.0'

也OK  

总结一下解决办法:

办法一:

implementation 'androidx.recyclerview:recyclerview:1.1.0'

 <androidx.recyclerview.widget.RecyclerView
            android:id="@+id/rv_topic"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"/>

办法二:

implementation 'androidx.recyclerview:recyclerview:1.3.0'
<androidx.recyclerview.widget.RecyclerView
            android:id="@+id/rv_topic"
            android:overScrollMode="never"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"/>

收工!

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

TouchOfSun

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值