Open miskiyang opened 3 years ago
问个问题,是compileSdkVersion == 30 才会报错 还是,android 11 的手机都会报错?
----------------更新--------------------
奇怪,我用 compileSdkVersion = 30 minSdkVersion = 21 targetSdkVersion = 30
这个配置是去编译,然后跑在android 11的模拟器上,并没有崩溃
想问下用的是AndroidX版本么?目前我这边的项目也在用但没遇到这个问题
想问下用的是AndroidX版本么?目前我这边的项目也在用但没遇到这个问题
我用的androidX版本但没有崩溃,等我的小米9更新android11后我再测试,但是考虑到android越来越严厉的策略,感觉确实应该减少反射的使用
MessageDialog不存在反射
发件人: ppg408331701 notifications@github.com 发送时间: Tuesday, December 22, 2020 9:11:16 AM 收件人: kongzue/DialogV3 DialogV3@noreply.github.com 抄送: Kongzue myzcxhh@live.cn; Comment comment@noreply.github.com 主题: Re: [kongzue/DialogV3] 关于dialog报错问题:Expected receiver of type android.app.AlertDialog, but got java.lang.ref.WeakReference (#221)
想问下用的是AndroidX版本么?目前我这边的项目也在用但没遇到这个问题
我用的androidX版本但没有崩溃,等我的小米9更新android11后我再测试,但是考虑到android越来越严厉的策略,感觉确实应该减少反射的使用
― You are receiving this because you commented. Reply to this email directly, view it on GitHubhttps://apac01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fkongzue%2FDialogV3%2Fissues%2F221%23issuecomment-749281845&data=04%7C01%7C%7C10118381177a4d8c557f08d8a6167d1f%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C637441962802323037%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=tgkVPTjnxfNB5oQfARvMWjOtkP9FPZb6ezt5nyNbP0U%3D&reserved=0, or unsubscribehttps://apac01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fnotifications%2Funsubscribe-auth%2FACNFSH7JYOXUTHIK4MGRRQ3SV7W3JANCNFSM4U363Y4Q&data=04%7C01%7C%7C10118381177a4d8c557f08d8a6167d1f%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C637441962802328035%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=A3cSWFA%2F7VpiEDSVnkZsbF5mFqFYXz15PWLI1fqPJlk%3D&reserved=0.
我也存在这个问题
问个问题,是compileSdkVersion == 30 才会报错 还是,android 11 的手机都会报错?
----------------更新--------------------
奇怪,我用 compileSdkVersion = 30 minSdkVersion = 21 targetSdkVersion = 30
这个配置是去编译,然后跑在android 11的模拟器上,并没有崩溃
并不是崩溃,而是引用历史缓存的dailog由于拿不到导致dialog显示不出来,你可以做个简单的测试,在你测试的demo开启messagedialog,然后点击dialog关闭后跳转到其他app,然后在onresume将该dialog带出来,有时候就会带不出来,带不出来的时候就会有这个错误提示
MessageDialog不存在反射 … ____ 发件人: ppg408331701 notifications@github.com 发送时间: Tuesday, December 22, 2020 9:11:16 AM 收件人: kongzue/DialogV3 DialogV3@noreply.github.com 抄送: Kongzue myzcxhh@live.cn; Comment comment@noreply.github.com 主题: Re: [kongzue/DialogV3] 关于dialog报错问题:Expected receiver of type android.app.AlertDialog, but got java.lang.ref.WeakReference (#221) 想问下用的是AndroidX版本么?目前我这边的项目也在用但没遇到这个问题 我用的androidX版本但没有崩溃,等我的小米9更新android11后我再测试,但是考虑到android越来越严厉的策略,感觉确实应该减少反射的使用 ― You are receiving this because you commented. Reply to this email directly, view it on GitHubhttps://apac01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fkongzue%2FDialogV3%2Fissues%2F221%23issuecomment-749281845&data=04%7C01%7C%7C10118381177a4d8c557f08d8a6167d1f%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C637441962802323037%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=tgkVPTjnxfNB5oQfARvMWjOtkP9FPZb6ezt5nyNbP0U%3D&reserved=0, or unsubscribehttps://apac01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fnotifications%2Funsubscribe-auth%2FACNFSH7JYOXUTHIK4MGRRQ3SV7W3JANCNFSM4U363Y4Q&data=04%7C01%7C%7C10118381177a4d8c557f08d8a6167d1f%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C637441962802328035%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=A3cSWFA%2F7VpiEDSVnkZsbF5mFqFYXz15PWLI1fqPJlk%3D&reserved=0.
我引用的版本不对嘛?我这边看代码是:630行,而且AlertDialog和androidx无关,这个属于android自身的 Field mAlert = AlertDialog.class.getDeclaredField("mAlert"); mAlert.setAccessible(true); Object mAlertController = mAlert.get(dialog);
MessageDialog不存在反射 … ____ 发件人: ppg408331701 notifications@github.com 发送时间: Tuesday, December 22, 2020 9:11:16 AM 收件人: kongzue/DialogV3 DialogV3@noreply.github.com 抄送: Kongzue myzcxhh@live.cn; Comment comment@noreply.github.com 主题: Re: [kongzue/DialogV3] 关于dialog报错问题:Expected receiver of type android.app.AlertDialog, but got java.lang.ref.WeakReference (#221) 想问下用的是AndroidX版本么?目前我这边的项目也在用但没遇到这个问题 我用的androidX版本但没有崩溃,等我的小米9更新android11后我再测试,但是考虑到android越来越严厉的策略,感觉确实应该减少反射的使用 ― You are receiving this because you commented. Reply to this email directly, view it on GitHubhttps://apac01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fkongzue%2FDialogV3%2Fissues%2F221%23issuecomment-749281845&data=04%7C01%7C%7C10118381177a4d8c557f08d8a6167d1f%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C637441962802323037%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=tgkVPTjnxfNB5oQfARvMWjOtkP9FPZb6ezt5nyNbP0U%3D&reserved=0, or unsubscribehttps://apac01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fnotifications%2Funsubscribe-auth%2FACNFSH7JYOXUTHIK4MGRRQ3SV7W3JANCNFSM4U363Y4Q&data=04%7C01%7C%7C10118381177a4d8c557f08d8a6167d1f%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C637441962802328035%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=A3cSWFA%2F7VpiEDSVnkZsbF5mFqFYXz15PWLI1fqPJlk%3D&reserved=0.
我引用的版本不对嘛?我这边看代码是:630行,而且AlertDialog和androidx无关,这个属于android自身的 Field mAlert = AlertDialog.class.getDeclaredField("mAlert"); mAlert.setAccessible(true); Object mAlertController = mAlert.get(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)