-
Notifications
You must be signed in to change notification settings - Fork 163
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
关于dialog报错问题:Expected receiver of type android.app.AlertDialog, but got java.lang.ref.WeakReference #221
Comments
问个问题,是compileSdkVersion == 30 才会报错 ----------------更新-------------------- 奇怪,我用 这个配置是去编译,然后跑在android 11的模拟器上,并没有崩溃 |
想问下用的是AndroidX版本么?目前我这边的项目也在用但没遇到这个问题 |
我用的androidX版本但没有崩溃,等我的小米9更新android11后我再测试,但是考虑到android越来越严厉的策略,感觉确实应该减少反射的使用 |
我也存在这个问题 |
并不是崩溃,而是引用历史缓存的dailog由于拿不到导致dialog显示不出来,你可以做个简单的测试,在你测试的demo开启messagedialog,然后点击dialog关闭后跳转到其他app,然后在onresume将该dialog带出来,有时候就会带不出来,带不出来的时候就会有这个错误提示 |
刚刚查了下,这段代码是用于设置AlertDialog的按钮文字样式的,因为Google并没有公开的设置方法不得不这么做。因历史原因,DialogV3框架依然是基于DialogFragment进行的实现,现在我更推荐更新到DialogX这个库( https://github.com/kongzue/DialogX )它的Material主题Dialog是纯粹自己做的实现,不存在这些问题。 |
你好,我在sdk30也遇到了这个问题 |
我的compileSdkVersion 30
MessageDialog里面的showEvent方法反射获取AlertController报错,这个对象已经被标为@UnsupportedAppUsage,
不允许反射拿了,博主更新处理下这个问题
报错信息:
java.lang.IllegalArgumentException: Expected receiver of type android.app.AlertDialog, but got java.lang.ref.WeakReference
W/System.err: at java.lang.reflect.Field.get(Native Method)
W/System.err: at com.kongzue.dialog.v3.MessageDialog.showEvent(MessageDialog.java:630)
The text was updated successfully, but these errors were encountered: