This article introduces how to integrate TUIKit components.
Note:
Starting from version 5.7.1435, TUIKit supports modular integration and the classic UI. You can integrate the necessary modules according to your needs.
Starting from version 6.9.3557, TUIKit introduces a brand new minimalist UI.
You can freely choose between the classic or minimalist UI components according to your needs. If you are not familiar with the features of the UI libraries, you can refer to the document TUIKit Interface Libraries Introduction.
Development Environment Requirements
Android Studio-Giraffe
Gradle-7.2
Android Gradle Plugin Version-7.0.0
kotlin-gradle-plugin-1.5.31
Integrate Module Source Code
1. Download the TUIKit source code from GitHub. Ensure that the TUIKit folder is at the same level as your project folder, for example:
2. Add the corresponding TUI components to settings.gradle according to your business requirements. TUI components are independent of each other, and adding or removing them does not affect project compilation.
// Include the upper-layer app module
include ':app'
// Include the internal communication module (required module)
// Include chat message translation plugin, supported from version 7.2 (Value-added feature activation is required. Please contact Tencent Cloud sales)
// Include emoji reaction plugin, supported from version 7.8 (To use this module, you need to purchase the Pro Edition、Pro Plus edition or Enterprise edition)
The compatibility between Kotlin, Gradle, and AGP versions can be viewed here.
To respect the copyright of emoji designs, the Chat Demo/TUIKit project does not include cutouts of large emoji elements. Please replace them with your own designs or other emoji packs for which you hold the copyright before officially launching for commercial use. The default smiley face emoji pack shown below is copyrighted by Tencent RTC, you can upgrade to Chat Pro Plus Edition and Enterprise Edition to use it for free.
6. Sync the project, and compile and run it. The expected project structure is shown in the following figure:
7. [Optional] Delete unnecessary UI files
8. The classic and minimalist UI do not affect each other, and they can run independently. Their files are in each TUI component, in separate folders. Take TUIChat as an example:
The classicui folder stores the classic version UI files, while the minimalistui folder stores the minimalist version UI files. If you want to integrate the minimalist UI, just delete the classicui folder and the corresponding Activity and Service for the classic UI in the AndroidManifest.xml file.
Note:
The Classic and Minimalist UI cannot be mixed. When integrating multiple components, you must consistently choose either classic UI or minimalist UI. For example, the classic TUIChat must be used with the classic TUIConversation, classic TUIContact, and classic TUIGroup. Similarly, the minimalist TUIChat must be used with the minimalist TUIConversation, minimalist TUIContact, and minimalist TUIGroup.
How to handle error "Manifest merger failed : Attribute application@allowBackup value=(true) from AndroidManifest.xml"?
In the Chat SDK, the value of allowBackup is false by default, indicating that the backup and restore feature of the app is disabled.
You can delete the allowBackup property from the AndroidManifest.xml file to disable the backup and restore feature. You can also add tools:replace="android:allowBackup" to the application node of the AndroidManifest.xml file to overwrite the Chat SDK configuration with your own configuration.
How to handle error "NDK at /Users/***/Library/Android/sdk/ndk-bundle did not have a source.properties file"?
You only need to add your NDK path to the local.properties file. For example: ndk.dir=/Users/***/Library/Android/sdk/ndk/16.1.4479499
How to handle error "Cannot fit requested classes in a single dex file"?
The possible cause is that your API level is lower than expected. You need to enable MultiDex support in the build.gradle file in App and add multiDexEnabled true and the corresponding dependencies:
android {
defaultConfig {
...
minSdkVersion 19
targetSdkVersion 30
multiDexEnabled true
}
...
}
dependencies {
implementation "androidx.multidex:multidex:2.0.1"
}
In addition, add the following code to the Application file: