Giter Site home page Giter Site logo

chat-android's Introduction

环信/EaseIM


简介

环信App是基于环信SDK开发的一款完整的类微信的聊天APP。展示的功能包括:注册新用户,用户登录,添加好友,单聊,群聊,发送文字,表情,语音,图片,地理位置等消息,以及实时音视频通话等。

创建应用并获取AppKey

运行demo之前,请务必先到环信管理后台创建您自己的应用并获取到Appkey,然后将获取到的Appkey配置到AndroidManifest.xml中。

  <!-- 设置环信应用的AppKey -->
  <meta-data android:name="EASEMOB_APPKEY"  android:value="创建应用获取到的Appkey" />

注册并创建应用的详情介绍,请移步环信官网:注册并创建应用

如何集成环信IM SDK

请移步环信官网:Android SDK 介绍及导入

体验环信App

请移步环信官网:场景DEMO及源码下载

应用架构介绍

环信APP采用谷歌官方建议的应用架构: 此架构有如下优点:

(1)UI和业务逻辑解耦。
(2)有效避免生命周期组件内存泄漏。
(3)提高模块可测试性。
(4)提高应用稳定性,有效降低以下异常发生概率。

对于架构各部分的理解:

(1)Activity/Fragment为View层,主要是负责数据的展示刷新和交互事件的触发。
(2)ViewModel 是用来保存应用UI数据的类,它会在配置变更(Configuration Change)后继续存在。
(3)LiveData是一个具有生命周期感知特性的可观察的数据保持类。
(4)Repository(仓库),主要是用于各种数据的业务请求操作( 网络请求和数据库查询), 可以把它看作 Model 层的 一部分。
(5)Room 是在 Sqlite 之上添加的一个抽象层, 以便实现更加强大的数据库访问,其可直接返回 LiveData, 用于监听数据返回。

工具要求

(1)Android Studio 3.2或更高版本。
(2)SDK targetVersion至少为26。

项目结构介绍

1、项目结构

项目分为主module和两个本地依赖库。
easeui是环信为了方便开发者快速使用环信SDK开发的UI库。
player是播放视频库,依赖于easeui。

2、主要功能介绍 项目是按照功能块进行项目分类,主要的功能块包含如下:
聊天,会议,联系人,会话,群组及聊天室,系统消息及关于环信等模块

chat模块,包含了聊天相关类,包含了聊天页面及其相关类,聊天历史类,音视频通话类等
conference模块,主要是会议相关类
contact模块,包含联系人列表,添加联系人,黑名单等
converstaion模块,主要是会话列表相关
dialog模块,是各类DialogFragment
group模块,主要包含群组和聊天室相关功能
login模块,主要包含登录,注册等功能
me模块,包含了个人信息,通用设置,开发者设置等功能
message模块,主要是系统消息功能
search模块,主要是各类搜索页面

3、重要类介绍

ChatActivity: 会话页面,核心类,主要逻辑写在 ChatFragment 中。ChatFragment 继承自 EaseChatFragment,EaseChatFragment实现了聊天列表功能,包含了发送文字,表情,图片等功能;ChatFragment展示了对EaseChatFragment的功能扩展实践。
DemoApplication:继承于系统的 Application 类,其 onCreate() 为整个程序的入口,相关的初始化操作都在这里面;
DemoHelper: Demo 全局帮助类,主要功能为初始化 EaseUI、环信 SDK 及 Demo 相关的实例,以及封装一些全局使用的方法;
MainActivity: 主页面,包含会话列表页面(ConversationListFragment)、联系人列表页(ContactListFragment)、设置页面(AboutMeFragment);
ConversationListFragment:会话列表类,继承自EaseConversationListFragment。ConversationListFragment展示了对EaseConversationListFragment类的扩展;
ContactListFragment:联系人列表类,继承自EaseContactListFragment。ContactListFragment展示了对EaseContactListFragment类的扩展。

环信IM基本功能介绍

消息
好友管理
群组管理
聊天室管理
多设备登录

环信关于第三方推送的集成介绍

第三方推送集成
设置当前登录用户的推送昵称
离线推送问题排查

可能会遇到的问题

1、如果遇到Error: Default interface methods are only supported starting with Android N (--min-api 24)问题
需要指定JDK版本

android {
  ......

   //指定jdk版本
   compileOptions {
       sourceCompatibility JavaVersion.VERSION_1_8
       targetCompatibility JavaVersion.VERSION_1_8
   }

}

2、解决Android9.0以上强制使用https的问题

解决办法可以参考:StackOverFlow,也可以直接在AndroidManifest.xml文件的application标签中设置android:usesCleartextTraffic=“true”

<application 
   android:usesCleartextTraffic="true" > 
  ......
</application>

3、从github拉取源码,运行demo,遇到登录报缺失Appkey及注册demo崩溃

请先到环信管理后台创建您自己的应用并获取到Appkey,然后将获取到的Appkey配置到AndroidManifest.xml中。

  <!-- 设置环信应用的AppKey -->
  <meta-data android:name="EASEMOB_APPKEY"  android:value="创建应用获取到的Appkey" />

注册并创建应用的详情介绍,请移步环信官网:注册并创建应用

相关文档

请参考集成文档: http://docs-im.easemob.com/im/android/sdk/import

chat-android's People

Contributors

apex-wang avatar githubzhaoliang avatar jinanzhuan avatar lijian1122 avatar wangxinjeff avatar xuchengpu avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

chat-android's Issues

强制踢下线问题

关于kickAllDevices 方法使用
报错
java.lang.UnsatisfiedLinkError: No implementation found for void com.hyphenate.chat.adapter.EMAError.nativeInit() (tried Java_com_hyphenate_chat_adapter_EMAError_nativeInit and Java_com_hyphenate_chat_adapter_EMAError_nativeInit__)

编译失败

bg:
mac pro m2
Android Studio Flamingo | 2022.2.1 Patch 2


FAILURE: Build completed with 3 failures.

1: Task failed with an exception.

  • What went wrong:
    Execution failed for task ':app:mergeDebugResources'.

Multiple task action failures occurred:
A failure occurred while executing com.android.build.gradle.internal.res.Aapt2CompileRunnable
> AAPT2 aapt2-4.2.2-7147631-osx Daemon #2: Daemon startup failed
This should not happen under normal circumstances, please file an issue if it does.
A failure occurred while executing com.android.build.gradle.internal.res.Aapt2CompileRunnable
> AAPT2 aapt2-4.2.2-7147631-osx Daemon #5: Daemon startup failed
This should not happen under normal circumstances, please file an issue if it does.
A failure occurred while executing com.android.build.gradle.internal.res.Aapt2CompileRunnable
> AAPT2 aapt2-4.2.2-7147631-osx Daemon #7: Daemon startup failed
This should not happen under normal circumstances, please file an issue if it does.
A failure occurred while executing com.android.build.gradle.internal.res.Aapt2CompileRunnable
> AAPT2 aapt2-4.2.2-7147631-osx Daemon #4: Daemon startup failed
This should not happen under normal circumstances, please file an issue if it does.
A failure occurred while executing com.android.build.gradle.internal.res.Aapt2CompileRunnable
> AAPT2 aapt2-4.2.2-7147631-osx Daemon #0: Daemon startup failed
This should not happen under normal circumstances, please file an issue if it does.
A failure occurred while executing com.android.build.gradle.internal.res.Aapt2CompileRunnable
> AAPT2 aapt2-4.2.2-7147631-osx Daemon #1: Daemon startup failed
This should not happen under normal circumstances, please file an issue if it does.
A failure occurred while executing com.android.build.gradle.internal.res.Aapt2CompileRunnable
> AAPT2 aapt2-4.2.2-7147631-osx Daemon #3: Daemon startup failed
This should not happen under normal circumstances, please file an issue if it does.
A failure occurred while executing com.android.build.gradle.internal.res.Aapt2CompileRunnable
> AAPT2 aapt2-4.2.2-7147631-osx Daemon #6: Daemon startup failed
This should not happen under normal circumstances, please file an issue if it does.

  • Try:
    Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
    ==============================================================================

2: Task failed with an exception.

  • What went wrong:
    Execution failed for task ':app:processDebugMainManifest'.

Unable to make field private final java.lang.String java.io.File.path accessible: module java.base does not "opens java.io" to unnamed module @12bc101e

  • Try:
    Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
    ==============================================================================

3: Task failed with an exception.

  • What went wrong:
    Execution failed for task ':app:processDebugAndroidTestResources'.

A failure occurred while executing com.android.build.gradle.internal.res.LinkApplicationAndroidResourcesTask$TaskAction
AAPT2 aapt2-4.2.2-7147631-osx Daemon #8: Daemon startup failed
This should not happen under normal circumstances, please file an issue if it does.

  • Try:
    Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
    ==============================================================================

  • Get more help at https://help.gradle.org

BUILD FAILED in 24s
42 actionable tasks: 42 executed


Task :app:mergeDebugResources FAILED
Task :app:processDebugMainManifest FAILED
Task :app:processDebugAndroidTestResources FAILED
Cause: error=86, Bad CPU type in executable

关于本地数据库

本地数据库保存消息 能加上注释吗 不知道在那里设置聊天对象的昵称 和头像 保存昵称和头像的方法有但是 不知道怎么用

User authentication failed

demo 加了appkey 用不了啊! 登录报错,下面同样的问题 也没解决啊,为什么给客户用的demo也登录不了?开发 吃shit长大的吗

找不到类文件

发送/接收图片消息时用到类:com.hyphenate.easeui.utils.EaseFileUtils中有引用com.hyphenate.util.EMFileHelper。但是没有找到对应的包和类。同样的还有com.hyphenate.util.EMLog也找不到。
public static boolean isFileExistByUri(Context context, Uri fileUri) { return EMFileHelper.getInstance().isFileExist(fileUri); }

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.