tencent cloud

Tencent Real-Time Communication

소식 및 공지 사항
제품 업데이트
Tencent Cloud 오디오/비디오 단말 SDK 재생 업그레이드 및 권한 부여 인증 추가
TRTC 월간 구독 패키지 출시 관련 안내
제품 소개
제품 개요
기본 개념
제품 기능
제품 장점
응용 시나리오
성능 데이터
구매 가이드
Billing Overview
무료 시간 안내
Monthly subscription
Pay-as-you-go
TRTC Overdue and Suspension Policy
과금 FAQ
Refund Instructions
신규 사용자 가이드
Demo 체험
Call
개요(TUICallKit)
Activate the Service
Run Demo
빠른 통합(TUICallKit)
오프라인 푸시
Conversational Chat
온클라우드 녹화(TUICallKit)
AI Noise Reduction
UI 사용자 정의
Calls integration to Chat
Additional Features
No UI Integration
Server APIs
Client APIs
Solution
ErrorCode
릴리스 노트
FAQs
라이브 스트리밍
Billing of Video Live Component
Overview
Activating the Service (TUILiveKit)
Demo 실행
No UI Integration
UI Customization
Live Broadcast Monitoring
Video Live Streaming
Voice Chat Room
Advanced Features
Client APIs
Server APIs
Error Codes
Release Notes
FAQs
RTC Engine
Activate Service
SDK 다운로드
API 코드 예시
Usage Guidelines
API 클라이언트 API
고급 기능
RTC RESTFUL API
History
Introduction
API Category
Room Management APIs
Stream mixing and relay APIs
On-cloud recording APIs
Data Monitoring APIs
Pull stream Relay Related interface
Web Record APIs
AI Service APIs
Cloud Slicing APIs
Cloud Moderation APIs
Making API Requests
Call Quality Monitoring APIs
Usage Statistics APIs
Data Types
Appendix
Error Codes
콘솔 가이드
애플리케이션 관리
사용량 통계
모니터링 대시보드
개발 보조
Solution
Real-Time Chorus
FAQs
과금 개요
기능 관련
UserSig 관련
방화벽 제한 처리
설치 패키지 용량 축소 관련 질문
Andriod 및 iOS 관련
Web 관련
Flutter 관련
Electron 관련
TRTCCalling Web 관련
멀티미디어 품질 관련
기타 질문
Protocols and Policies
컴플라이언스 인증
보안 백서
정보 보안에 관한 참고 사항
Service Level Agreement
Apple Privacy Policy: PrivacyInfo.xcprivacy
TRTC 정책
개인 정보 보호 정책
데이터 처리 및 보안 계약
용어집

Preparation(Android)

PDF
포커스 모드
폰트 크기
마지막 업데이트 시간: 2025-12-25 12:10:53

Feature Overview

TUILiveKit is a comprehensive live-streaming component. Once integrated, it allows you to quickly implement the following key functional modules for your Android application:
Host Prepare Page
Host Streaming Page
Live Stream List
Audience Viewing Page













Preparations

Activate Service

Before using TUILiveKit, please refer to Activate Service to get the TUILiveKit trial version or activate the paid version.

Environment Requirements

Android Studio Arctic Fox (2020.3.1) or a later version.
Gradle 7.0 or a later version.
Android 5.0 or a later version.

Code Integration

Step 1. Download the TUILiveKit Component

Clone or download the code from GitHub. Then, copy the live and atomic_x subdirectory into the same directory as your current Android project's app folder.


Step 2. Project Configuration

1. Configure the JitPack Repository

In your project's root directory, open the settings.gradle.kts or settings.gradle file and add the JitPack repository address. The third-party library for playing gift SVG animations is hosted on JitPack, so you must include this repository to resolve dependencies.
settings.gradle.kts
settings.gradle
dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories {
google()
mavenCentral()

// Add JitPack repository url
maven { url = uri("https://jitpack.io") }
}
}
dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories {
google()
mavenCentral()

// Add JitPack repository url
maven { url 'https://jitpack.io' }
}
}

2. Import the TUILiveKit Component

In your project's root directory, add the following line to the settings.gradle.kts or settings.gradle file to import the TUILiveKit component (as a module).
settings.gradle.kts
settings.gradle
include ':tuilivekit'
project(':tuilivekit').projectDir = new File(settingsDir, "live/tuilivekit")

include(":atomic")
project(':atomic').projectDir = new File(settingsDir, "atomic_x")
include ':tuilivekit'
project(':tuilivekit').projectDir = new File(settingsDir, "live/tuilivekit")

include(":atomic")
project(':atomic').projectDir = new File(settingsDir, "atomic_x")

3. Adding Component Dependency

Navigate to the app directory and find the build.gradle.kts or build.gradle file. Add the following dependency to declare that your app module relies on the newly added TUILiveKit component module.
build.gradle.kts
build.gradle
dependencies {
// Add tuilivekit dependency
api(project(":tuilivekit"))
}
dependencies {
// Add tuilivekit dependency
api project(':tuilivekit')
}
Note:
TUILiveKit has default dependencies on public libraries like the TRTC SDK and IM SDK, so you do not need to configure them separately.

4. Configure Proguard Rules

Since the SDK uses Java reflection internally, you must add the following rules to the proguard-rules.pro file. This prevents the relevant classes from being obfuscated, ensuring proper function.
-keep class com.tencent.** { *; }
-keep class com.tencent.beacon.** { *; }
-keep class com.tencent.cloud.iai.lib.** { *; }
-keep class com.tencent.qimei.** { *; }
-keep class com.tencent.xmagic.** { *; }
-keep class com.trtc.uikit.livekit.component.gift.store.model.** { *; }
-keep class com.trtc.uikit.livekit.livestreamcore.** { *; }
-keep class com.tcmediax.** { *; }

# Obfuscation rules for Google's serialization/deserialization framework Gson library
-keep class com.google.gson.** { *; }

# Obfuscation rules for beauty effect
-keep class androidx.exifinterface.** { *; }
-keep class com.gyailib.** { *; }
-keep class org.extra.** { *; }
-keep class org.libpag.** { *; }
-keep class org.light.** { *; }

# Obfuscation rules for playing gifts SVG animation
-keep class com.opensource.svgaplayer.proto.** { *; }
-keep class com.squareup.wire.** { *; }

5. Modify AndroidManifest.xml

To prevent conflicts during the AndroidManifest merge process, you must add tools:replace="android:allowBackup" and android:allowBackup="false" to the <application> node in your app/src/main/AndroidManifest.xml file. This overrides the settings within the component and disables the backup feature.
<application
...
// Add the following configuration to override the settings in the dependent SDK
android:allowBackup="false"
tools:replace="android:allowBackup">

6. Complete Project Sync

After completing the steps above, Android Studio will typically prompt you with a Sync Now button. Click this button to complete the project synchronization. If the IDE doesn't prompt you automatically, manually click the sync button in the toolbar. Once synchronized, the IDE will finish project configuration and indexing, allowing you to use the TUILiveKit component in your project.


Complete Login

After code integration, the next step is to complete the login. All TUILiveKit features require a successful login to function properly, so ensure your parameters are configured correctly.
Note:
In the example code, the login API is called directly. However, in a real-world application, it is highly recommended that you call the TUILiveKit login service only after your own user authentication and other internal login processes are complete. This prevents potential business logic confusion or data inconsistency caused by calling the login service too early, and it better aligns with your existing user management system.
Kotlin
Java
// 1. Import dependency
import com.tencent.qcloud.tuicore.TUILogin

// 2. Call the login API. It is recommended to call TUILogin after your own login business is completed.
TUILogin.login(applicationContext,
1400000001, // Please replace with the SDKAppID from the service activation console
"denny", // Please replace with your UserID
"xxxxxxxxxxx", // You can generate a UserSig in the console and fill it in here
object : TUICallback() {
override fun onSuccess() {
Log.i(TAG, "login success")
}

override fun onError(errorCode: Int, errorMessage: String) {
Log.e(TAG, "login failed, errorCode: $errorCode msg:$errorMessage")
}
})
// 1. Import dependency
import com.tencent.qcloud.tuicore.TUILogin

// 2. Call the login API. It is recommended to call TUILogin after completing your own login service.
TUILogin.login(context,
1400000001, // Please replace with the SDKAppID from the service activation console
"denny", // Please replace with your UserID
"xxxxxxxxxxx", // You can generate a UserSig in the console and fill it in here
new TUICallback() {
@Override
public void onSuccess() {
Log.i(TAG, "login success");
}

@Override
public void onError(int errorCode, String errorMessage) {
Log.e(TAG, "login failed, errorCode: " + errorCode + " msg:" + errorMessage);
}
});
Login API Parameter Description
Parameter
Type
Description
SDKAppID
Int
UserID
String
The unique ID for the current user. Must contain only English letters, numbers, hyphens, and underscores.
userSig
String
A ticket for Tencent Cloud authentication. Please note:
Development Environment: You can use the local GenerateTestUserSig.genTestSig function to generate a UserSig or generate a temporary UserSig via the UserSig Generation Tool.
Production Environment: To prevent key leakage, you must use a server-side method to generate UserSig. For details, see Generating UserSig on the Server.
For more information, see How to Calculate and Use UserSig.

Handling Login Exception Status [Optional]

TUILogin provides a login status callback mechanism to help you handle possible login exceptions, mainly including "kicked offline" and "signature expired" callbacks:
Kicked Offline: If a user is kicked offline while online, the SDK will notify you via the onKickedOffline callback. At this point, you can display a UI prompt to the user and call TUILogin.login to login again.
Signature Expired: If a user receives the onUserSigExpired callback while online, it means the userSig previously issued for that user has expired. If the user's login session on your backend is still valid, you can have your app request a new userSig from your backend and call TUILogin.login to renew the login session.
kotlin
java
class YourLoginService : TUILoginListener() {

// Listen to login status callback
fun addObserver() {
TUILogin.addLoginListener(this)
}

// Cancel listening for login status callback
fun removeObserver() {
TUILogin.removeLoginListener(this)
}

// User kicked offline callback
override fun onKickedOffline() {
// Your business code: UI prompts the user, then log in again
}

// User signature expired callback
override fun onUserSigExpired() {
// Your business code: If the current user is still logged in on your backend, you can let your app request a new userSig from the backend and call TUILogin.login to renew the login status.
}
}
class YourLoginService extends TUILoginListener {

// Listen to login status callback
public void addObserver() {
TUILogin.addLoginListener(this);
}

// Cancel listening for login status callback
public void removeObserver() {
TUILogin.removeLoginListener(this);
}

// User kicked offline callback
@Override
public void onKickedOffline() {
// Your business code: UI prompts the user, then log in again
}

// User signature expired callback
@Override
public void onUserSigExpired() {
// Your business code: If the current user is still logged in on your backend, you can let your app request a new userSig from the backend and call TUILogin.login to renew the login status.
}
}

Next Steps

Congratulations! You have successfully integrated the TUILiveKit component and completed the login. You can now implement features such as host streaming, viewer watching, and the live stream list. Please refer to the table below for integration guides:
Feature
Description
Integration Guide
Host Streaming
The complete workflow for a host to start a stream, including pre-stream setup and various in-stream interactions.
Audience Viewing
Audience can watch live streaming after entering the anchor's live streaming room, with features like audience mic connection, live room information, online audience, and bullet screen display.
Live Stream List
Display the live stream list interface and features, including the live stream list and room information display.

FAQs

Do I need to call the login API every time I enter a room?

No. You typically only need to call TUILogin.login once. We recommend associating TUILogin.login and TUILogin.logout with your app's own user login and logout business logic.

How do I handle the allowBackup compilation error shown in the figure below after code integration?




Reason: The allowBackup attribute is configured in the AndroidManifest.xml of multiple modules, which causes a conflict during the manifest merge process.
Solution: In your project's AndroidManifest.xml file, you can either delete the allowBackup attribute or change it to false to disable backup and restore functionality. Crucially, add tools:replace="android:allowBackup" to the <application> node to override the settings of other modules with your own configuration. See the example fix:




After code integration, do I still need to explicitly declare camera and microphone permissions?

No, TUILiveKit already has built-in declarations for permissions like the camera and microphone in its manifest file. You do not need to worry about declaring these permissions separately during the integration process.



도움말 및 지원

문제 해결에 도움이 되었나요?

피드백