From b4ee00edf1016f2f4af35bbd25d65803a327434c Mon Sep 17 00:00:00 2001 From: imndx Date: Fri, 18 Dec 2020 18:47:35 +0800 Subject: [PATCH] fix proguard issue --- chat/proguard-rules.pro | 4 ++++ .../java/cn/wildfirechat/remote/ChatManager.java | 13 +++++++------ 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/chat/proguard-rules.pro b/chat/proguard-rules.pro index d8240fb9b..5cc09224f 100644 --- a/chat/proguard-rules.pro +++ b/chat/proguard-rules.pro @@ -74,6 +74,10 @@ (...); } +-keepclassmembers class cn.wildfirechat.message.MessageContent { + encode(); +} + -keep class net.sourceforge.pinyin4j.** { *;} diff --git a/client/src/main/java/cn/wildfirechat/remote/ChatManager.java b/client/src/main/java/cn/wildfirechat/remote/ChatManager.java index 59eed1092..b26e9cbef 100644 --- a/client/src/main/java/cn/wildfirechat/remote/ChatManager.java +++ b/client/src/main/java/cn/wildfirechat/remote/ChatManager.java @@ -1327,12 +1327,13 @@ private void validateMessageContent(Class msgContentCl throw new IllegalArgumentException(className + ", custom messageContent class must have a default constructor,自定义消息必须要有一个默认的无参构造函数,请参考TextMessageContent.java"); } - try { - msgContentClazz.getDeclaredMethod("encode"); - } catch (NoSuchMethodException e) { - e.printStackTrace(); - throw new IllegalArgumentException(className + ", custom messageContent class must override encode,自定义消息必须覆盖encode方法,并调用super.encode(),请参考TextMessageContent.java"); - } + // 建议打开,以便对自定义消息的合法性进行检查 +// try { +// msgContentClazz.getDeclaredMethod("encode"); +// } catch (NoSuchMethodException e) { +// e.printStackTrace(); +// throw new IllegalArgumentException(className + ", custom messageContent class must override encode,自定义消息必须覆盖encode方法,并调用super.encode(),请参考TextMessageContent.java"); +// } try { Field creator = msgContentClazz.getDeclaredField("CREATOR");