Blankj / AndroidUtilCode

:fire: Android developers should collect the following utils(updating).
https://blankj.com/2016/07/31/android-utils-code/
Apache License 2.0
33.32k stars 10.69k forks source link

ToastUtils在ColorOS 6 上报java.lang.NoSuchMethodError #1059

Closed hystrixis closed 4 years ago

hystrixis commented 5 years ago

ToastUtils在ColorOS 6 上报java.lang.NoSuchMethodError

弹出Toast报错,页面无任何显示

The code of bug

 ToastUtils.showShort(message);

The stack of crash

 W/System.err: java.lang.NoSuchFieldException: No field mActivityList in class Landroid/app/ActivityThread; (declaration of 'android.app.ActivityThread' appears in /system/framework/framework.jar)
 at java.lang.Class.getDeclaredField(Native Method)
at com.blankj.utilcode.util.Utils$ActivityLifecycleImpl.getTopActivityByReflect(Utils.java:488)
at com.blankj.utilcode.util.Utils$ActivityLifecycleImpl.getTopActivity(Utils.java:386)
at com.blankj.utilcode.util.Utils.getTopActivityOrApp(Utils.java:134)
at com.blankj.utilcode.util.ToastUtils$ToastWithoutNotification.realShow(ToastUtils.java:467)
at com.blankj.utilcode.util.ToastUtils$ToastWithoutNotification.access$800(ToastUtils.java:427)
at com.blankj.utilcode.util.ToastUtils$ToastWithoutNotification$2.run(ToastUtils.java:453)
at android.os.Handler.handleCallback(Handler.java:873)

Screenshots

None

Blankj commented 5 years ago

你是在后台 show 的吧?没有 activity 直接 show 的吧?

hystrixis commented 5 years ago

在Activity中show的,但是关闭了通知栏权限才会弹出的,没关闭是正常的

Blankj commented 5 years ago

错误就是没有通知权限,然后也没有 Activity 时你 show 了。

Blankj commented 5 years ago

这个也只是 catch 输出了异常,并没有崩溃呀

hystrixis commented 5 years ago

是的,调用show方法无法弹Toast,Activity是正常显示的