在线客服软件海豚客服安卓SDK如何接入

本文详细介绍了如何在安卓项目中接入海豚客服SDK,包括修改gradle文件、添加依赖、配置权限和组件、处理资源冲突、混淆设置等步骤,确保SDK正常运行。
摘要由CSDN通过智能技术生成

本篇分享在线客服系统海豚客服如何进行安卓SDK的接入,首先请点击下载SDK包:“dolphin_lib-release.aar

一.将最小编译版本修改为17或者以上,通常在主module(通常名字为“app”)下gradle文件内添加或者修改,如

android {
   
  compileSdkVersion 30
  buildToolsVersion "30.0.3"
  defaultConfig {
   
    applicationId "com.example.dolphin_sdk_demo"
    minSdkVersion 17
    targetSdkVersion 30
    versionCode 1
    versionName "1.0"
  }
}

二.项目根节点下的gradle文件内添加如下代码

flatDir {
   
  dirs 'libs'
}

并在allprojects内repositories内添加

maven {
    url "https://jitpack.io" }

本文档附上具体添加位置如下

allprojects {
   
  repositories {
   
    flatDir {
   
      dirs 'libs'
    }
    maven {
    url "https://jitpack.io" }
    maven {
    url 'http://maven.aliyun.com/nexus/content/groups/public/' }
    maven {
    url 'http://maven.aliyun.com/nexus/content/repositories/jcenter' }
    maven {
    url 'http://maven.aliyun.com/nexus/content/repositories/google' }
    maven {
    url 'http://maven.aliyun.com/nexus/content/repositories/gradle-plugin' }
  }
}

三.将下载好的本SDK的aar包放到主module下libs目录下,目录索引如图
在这里插入图片描述
四.主module下gradle文件内添加依赖以导入aar包,如下

implementation(name: 'dolphin_lib-release', ext: 'aar')

五.除了添加aar包的依赖外,还要添加SDK所需依赖,成功运行SDK需要以下所有依赖,如果本身的项目里已经有其中部分依赖,则保留最新版本而去掉其他低版本

dependencies {
   
  implementation(name: 'dolphin_lib-release', ext: 'aar')

  implementation 'androidx.appcompat:appcompat:1.2.0'
  implementation 'com.google.android.material:material:1.2.1'
  implementation 'androidx.constraintlayout:constraintlayout:2.0.2'
  //Glide
  implementation 'com.github.bumptech.glide:glide:4.11.0'
  annotationProcessor 'com.github.bumptech.glide:compiler:4.11.0'
  implementation 'com.github.bumptech.glide:okhttp3-integration:4.11.0'
  //EventBus
  implementation 'org.greenrobot:eventbus:3.0.0'
  //dagger-rxjava2-retrofit2-okhttp3
  implementation 'com.google.dagger:dagger:2.23.2'
  annotationProcessor 'com.google.dagger:dagger-compiler:2.23.2'
  implementation 'io.reactivex.rxjava2:rxjava:2.2.5'
  implementation 'io.reactivex.rxjava2:rxandroid:2.0.2'
  implementation 'com.squareup.retrofit2:retrofit:2.6.0'
  implementation 'com.squareup.retrofit2:adapter-rxjava2:2.6.0'
  implementation 'com.squareup.retrofit2:converter-gson:2.6.0'
  implementation 'com.trello.rxlifecycle2:rxlifecycle-android:2.2.2'
  implementation 'com.trello.rxlifecycle2:rxlifecycle-components:2.2.2'
  implementation 'com.squareup.okhttp3:okhttp:3.12.1'
  //单Activity+多Fragment
  implementation 'me.yokeyword:fragmentationx:1.0.2'
  implementation 'me.yokeyword:fragmentationx-swipeback:1.0.2'
  implementation 'me.yokeyword:eventbus-activity-scope:1.1.0'
  //WebSocket收发消息
  implementation 'org.java-websocket:Java-WebSocket:1.3.6'
  api 'com.github.NaikSoftware:StompProtocolAndroid:1.6.4'
}

六.清单配置文件AndroidManifest.xml中添加权限、相关Activity和Service注册以及其他设置,如下:

1.权限(manifest节点下添加,不需要代码动态申请,因为SDK内已经有此类逻辑了)

<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<!-- SDCard读写数据权限 -->
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<!-- 系统照相机拍照 -->
<uses-permission android:name="android.permission.CAMERA" />

2.AndroidManifest.xml中application节点设置属性

android:allowBackup="true"
android:requestLegacyExternalStorage="true"
android:supportsRtl="true"

具体位置如下图在这里插入图片描述
3.AndroidManifest.xml中application节点下添加以下代码(SDK所需Activity与Service注册以及其他数据)

<service
  android:name="com.yiju.dolphin_lib.service.MsgService"
  android:enabled="true"
  android:exported="true" />
<activity
  android:name="com.yiju.dolphin_lib.pages.activity.SessionActivity"
  android:exported="true"
  android:launchMode="singleTask"
  android:screenOrientation="portrait"
  android:theme="@style/Lib_MainActivityTheme"
  android:windowSoftInputMode="adjustResize|stateHidden" />
<activity
  android:name="com.yiju.dolphin_lib.pages.activity.MediaActivity"
  android:launchMode="singleTop"
  android:theme="@style/Lib_MediaActivityTheme" />
<activity
  android:name="com.yiju.common.crop.CropImageActivity"
  android:theme="@style/Theme.MaterialComponents.Light.NoActionBar" />
<!-- 添加使用Apache HTTP client库,兼容安卓P -->
<uses-library
  android:name="org.apache.http.legacy"
  android:required="false" />
<provider
  android:name="androidx.core.content.FileProvider"
  android:authorities="${applicationId}.android7.fileprovider"
  android:exported="false"
  android:grantUriPermissions="true">
  <meta-data
      android:name="android.support.FILE_PROVIDER_PATHS"
      android:resource="@xml/file_paths" />
</provider>

4.兼容安卓7.0以上uri权限的配置

主module下res目录下添加xml目录&#

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值