下载凡信的源码到本地
凡信的github地址如下:
https://github.com/huangfangyi/FanXin2.0_IM.git
原作者还做了一个集成支付宝的体验版,可以下载并打赏。
http://120.24.211.126/fanxin/download/Fanxin.apk
导入到AS中
- 修改.9图片错误
- 修改完图片编译即可成功,但是运行到模拟器中会有以下错误
Message1
Error:Execution failed for task ':fanXin20:transformClassesWithDexForDebug'.> com.android.build.api.transform.TransformException: java.lang.RuntimeException: com.android.ide.common.process.ProcessException: java.util.concurrent.ExecutionException: com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command '/Library/Java/JavaVirtualMachines/jdk1.7.0_79.jdk/Contents/Home/bin/java'' finished with non-zero exit value 1
Gradle Console1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16AGPBI: {"kind":"error","text":"Exception in thread \"main\" java.lang.UnsupportedClassVersionError: com/android/dx/command/Main : Unsupported major.minor version 52.0","sources":[{}]}
AGPBI: {"kind":"error","text":"\tat java.lang.ClassLoader.defineClass1(Native Method)","sources":[{}]}
AGPBI: {"kind":"error","text":"\tat java.lang.ClassLoader.defineClass(ClassLoader.java:800)","sources":[{}]}
AGPBI: {"kind":"error","text":"\tat java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)","sources":[{}]}
AGPBI: {"kind":"error","text":"\tat java.net.URLClassLoader.defineClass(URLClassLoader.java:449)","sources":[{}]}
AGPBI: {"kind":"error","text":"\tat java.net.URLClassLoader.access$100(URLClassLoader.java:71)","sources":[{}]}
AGPBI: {"kind":"error","text":"\tat java.net.URLClassLoader$1.run(URLClassLoader.java:361)","sources":[{}]}
AGPBI: {"kind":"error","text":"\tat java.net.URLClassLoader$1.run(URLClassLoader.java:355)","sources":[{}]}
AGPBI: {"kind":"error","text":"\tat java.security.AccessController.doPrivileged(Native Method)","sources":[{}]}
AGPBI: {"kind":"error","text":"\tat java.net.URLClassLoader.findClass(URLClassLoader.java:354)","sources":[{}]}
AGPBI: {"kind":"error","text":"\tat java.lang.ClassLoader.loadClass(ClassLoader.java:425)","sources":[{}]}
AGPBI: {"kind":"error","text":"\tat sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)","sources":[{}]}
AGPBI: {"kind":"error","text":"\tat java.lang.ClassLoader.loadClass(ClassLoader.java:358)","sources":[{}]}
AGPBI: {"kind":"error","text":"\tat sun.launcher.LauncherHelper.checkAndLoadMain(LauncherHelper.java:482)","sources":[{}]}
FAILED
FAILURE: Build failed with an exception.
解决方法
将fanXin20下的build.gradle中的buildToolsVersion "24.0.0 rc2"
修改为buildToolsVersion "23.0.2"
即可正常运行到模拟器中
部分代码
User表
凡信中将环信的user实体类修改如下
1 | private int unreadMsgCount; |
重新封装了InviteMessage消息实体类1
2
3
4
5
6
7
8
9
10
11
12private String from;
//时间
private long time;
//添加理由
private String reason;
//未验证,已同意等状态
private InviteMesageStatus status;
//群id
private String groupId;
//群名称
private String groupName;
private int id;
从服务器拉取数据的工具类
图片异步加载类LoadDataFromServer
使用的HttpClient,但是数据都在服务器端。。。