Skip to content

Commit

Permalink
fix proguard issue
Browse files Browse the repository at this point in the history
  • Loading branch information
imndx committed Dec 18, 2020
1 parent e88da25 commit b4ee00e
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
4 changes: 4 additions & 0 deletions chat/proguard-rules.pro
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,10 @@
<init>(...);
}

-keepclassmembers class cn.wildfirechat.message.MessageContent {
encode();
}

-keep class net.sourceforge.pinyin4j.** { *;}


Expand Down
13 changes: 7 additions & 6 deletions client/src/main/java/cn/wildfirechat/remote/ChatManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -1327,12 +1327,13 @@ private void validateMessageContent(Class<? extends MessageContent> 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");
Expand Down

0 comments on commit b4ee00e

Please sign in to comment.