集成环信看了很多文档,还是不会,从官网下载的demo,也不会用,后来才发现应该下载官网的sdk,里面有个examples的文件夹,使用studio直接打开里面的ChatDemoUI3.0,就是一个可以运行的demo.运行的时候会报一个异常Error:Execution failed for task ':transformClassesWithJarMergingForDebug'.
> com.android.build.api.transform.TransformException: java.util.zip.ZipException: duplicate entry: android/support/multidex/MultiDex$V14.class
ChatDemoUI3.0的build文件有个依赖v7包的,我对照以前可以运行的项目发现,删除v7 的这一行,就可以了,可以运行起来.下面的集成大部分是仿照demo做的.
(原来只要删除这个v7包就能运行起来,其他的都不需要)
dependencies { compile project(':redpacketlibrary') compile project(':EaseUI') compile fileTree(include: '*.jar', exclude: 'android-support-multidex.jar', dir: 'libs') //考虑到在eclipse中,直接使用源码 // compile ('com.anthonycr.grant:permissions:1.0'){ // exclude module: 'support-v4' // } compile 'com.android.support:appcompat-v7:23.4.0' }
首先在环信官网下载sdk
解压后examples内的easeUI依赖到项目中,(easeUi包含simpledemo如果不需要可以删除)
根据examples内的ChatDemoUi将需要的文件考到自己的项目中
记得改清单文件的appkey以及ParseManager的parseAppId和ParseClientKey
第一步:ChatFragment
@Override public void onSetMessageAttributes(EMMessage message) { //设置消息扩展属性 message.setAttribute("name", MyApplication.myPreferences.getNickname());