Only  $9.9! Get 50,000 minutes with our Starter Plan, perfect for your MVP project.
Only $9.9! Get 50,000 minutes with our Starter Plan, perfect for your MVP project.
Grab It Now 
RTC Engine
Overview
  • Web
    • Demo Quick Run
    • SDK Quick Start
    • Basic Features
      • Screen Sharing
      • Live Streaming
      • Media Device
      • Audio Volume
      • Set Encoding Profile
      • Detect Network Quality
      • Detect Capabilities
    • Advance Features
      • Enable AI Denoiser
      • Enable Audio Mixer
      • Enable Watermark
      • Enable Beauty and Effects
      • SEI Message
      • Custom Capturing and Rendering
    • Best Practices
      • Optimize Multi-Person Video Calls
      • Handle Autoplay Restriction
      • Handle Firewall Restriction
    • API List
    • Released Notes
    • Supported Platforms
    • Web FAQs
  • Android
    • Integration
      • 1.API Examples
      • 2.Importing the SDK
      • 3.Entering a Room
      • 4.Subscribing to Audio/Video Streams
      • 5.Publish Audio/Video Streams
      • 6.Exiting a Room
      • 7.Sensing Network Quality
      • 8.Enabling Screen Sharing
      • 9.Setting Video Quality
      • 10.Rotating Videos
    • Testing Newwork Quality
    • Custom Capturing and Rendering
    • Custom Audio Capturing and Playback
    • Client APIs
      • Overview
      • TRTCCloud
      • TRTCStatistics
      • TRTCCloudListener
      • TXAudioEffectManager
      • TXBeautyManager
      • TXDeviceManager
      • Type Definition
      • Deprecated Interface
      • Error Codes
    • Release Notes
  • iOS
    • Integration
      • 1.API Examples
      • 2.Importing the SDK
      • 3.Entering a Room
      • 4.Subscribing to Audio/Video Streams
      • 5.Publish Audio/Video Streams
      • 6.Exiting a Room
      • 7.Sensing Network Quality
      • 8.Enabling Screen Sharing
      • 9.Setting Video Quality
      • 10.Rotating Videos
    • Testing Network Quality
    • Custom Capturing and Rendering
    • Custom Audio Capturing and Playback
    • Client APIs
      • Overview
      • TRTCCloud
      • TRTCCloudDelegate
      • TRTCStatistics
      • TXAudioEffectManager
      • TXBeautyManager
      • TXDeviceManager
      • Type Definition
      • Deprecated Interface
      • ErrorCode
    • Release Notes
  • macOS
    • Integration
      • 1.API Examples
      • 2.Importing the SDK
      • 3.Entering a Room
      • 4.Subscribing to Audio/Video Streams
      • 5.Publish Audio/Video Streams
      • 6.Exiting a Room
      • 7.Sensing Network Quality
      • 8.Enabling Screen Sharing
      • 9.Sharing Computer Audio
      • 10.Setting Video Quality
      • 11.Rotating Videos
    • Testing Hardware Devices
    • Testing Network Quality
    • Custom Capturing and Rendering
    • Custom Audio Capturing and Playback
    • Client APIs
      • Overview
      • TRTCCloud
      • TRTCCloudDelegate
      • TRTCStatistics
      • TXAudioEffectManager
      • TXBeautyManager
      • TXDeviceManager
      • Type Definition
      • Deprecated Interface
      • ErrorCode
      • Release Notes
    • Release Notes
  • Windows C++
    • Integration
      • 1.API Examples
      • 2.Importing the SDK
      • 3.Entering a Room
      • 4.Subscribing to Audio/Video Streams
      • 5.Publish Audio/Video Streams
      • 6.Exiting a Room
      • 7.Sensing Network Quality
      • 8.Enabling Screen Sharing
      • 9.Setting Video Quality
      • 10.Rotating Videos
    • Testing Hardware Devices
    • Testing Network Quality
    • Custom Capturing and Rendering
    • Custom Audio Capturing and Playback
    • Client APIs
      • Overview
      • ITRTCCloud
      • ITRTCStatistics
      • TRTCCloudCallback
      • ITXAudioEffectManager
      • ITXDeviceManager
      • Type Definition
      • Deprecated Interface
      • Error Codes
    • Release Notes
  • Electron
    • Integration
      • 1.API Examples
      • 2.Importing the SDK
      • 3.Entering a Room
      • 4.Subscribing to Audio/Video Streams
      • 5.Publish Audio/Video Streams
      • 6.Exiting a Room
      • 7.Sensing Network Quality
      • 8.Enabling Screen Sharing
      • 9.Sharing Computer Audio
      • 10.Setting Video Quality
      • 11.Rotating Videos
    • Client APIs
      • Overview
      • Error Codes
  • Flutter
    • Integration
      • 1.API Examples
      • 2.Importing the SDK
      • 3.Entering a Room
      • 4.Subscribing to Audio/Video Streams
      • 5.Publish Audio/Video Streams
      • 6.Exiting a Room
      • 7.Sensing Network Quality
      • 8.Enabling Screen Sharing
      • 9.Sharing Computer Audio
      • 10.Setting Video Quality
      • 11.Rotating Videos
    • Client APIs
      • Overview
      • Error Codes
  • Unity
    • Integration
      • 1.API Examples
      • 2Importing the SDK
    • Client APIs
      • Overview
      • Error Codes
  • Qt
    • Integration
      • 1.Importing the SDK
  • Overview
    • Overview
    • Features
    • Performance Statistics
  • Pricing
    • RTC-Engine Packages
    • Billing of On-Cloud Recording
    • Billing of MixTranscoding and Relay to CDN
    • Billing Explanation for Subscription Package Duration
    • Billing of Monitoring Dashboard
    • Free Minutes
    • Pay-As-You-Go
  • Concepts
  • FAQs
    • FAQs for Beginners
    • Migration Guide
      • Twilio Video to Tencent RTC
      • Billing
      • Features
      • UserSig
      • Firewall Restrictions
      • How to Downsize Installation Package
      • TRTCCalling for Web
      • Audio and Video Quality
      • Others
RTC Engine

2.Importing the SDK

This document describes how to import the SDK into your project.



Environment Requirements

Android Studio 3.5 or later.
Android 4.1 (SDK API level 16) or later

Step 1. Import the SDK

Method 1. Automatic loading (aar)

The TRTC SDK has been released to the mavenCentral repository, and you can configure Gradle to download updates automatically.
1. Add the TRTC SDK dependency to dependencies.
dependencies {
implementation 'com.tencent.liteav:LiteAVSDK_TRTC:latest.release'
}
2. In defaultConfig, specify the CPU architecture to be used by your application.
defaultConfig {
ndk {
abiFilters "armeabi-v7a", "arm64-v8a"
}
}
explain
Currently, the TRTC SDK supports armeabi-v7a, and arm64-v8a.
3. Click

Sync Now to automatically download the SDK and integrate them into your project.

Method 2. Download the SDK and import it manually

1. Download the SDK and decompress it locally.
2. Copy the decompressed AAR file to the app/libs directory of your project.
3. Add flatDir to build.gradle under your project's root directory to specify the local path for the repository.


4. Add code in app/build.gradle to import the AAR file.


5. In defaultConfig of app/build.gradle, specify the CPU architecture to be used by your application.
defaultConfig {
ndk {
abiFilters "armeabi", "armeabi-v7a", "arm64-v8a"
}
}
explain
Currently, the TRTC SDK supports armeabi, armeabi-v7a, and arm64-v8a.
6. Click

Sync Now to integrate the TRTC SDK.

Step 2. Configure app permissions

Configure application permissions in AndroidManifest.xml. The TRTC SDK requires the following permissions:
<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" />
<uses-permission android:name="android.permission.RECORD_AUDIO" />
<uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS" />
<uses-permission android:name="android.permission.BLUETOOTH" />
<uses-permission android:name="android.permission.CAMERA" />
<uses-feature android:name="android.hardware.camera.autofocus" />
notice
Do not set android:hardwareAccelerated="false". Disabling hardware acceleration will result in failure to render remote users' videos.

Step 3. Set obfuscation rules

In the proguard-rules.pro file, add the classes related to the TRTC SDK to the "do not obfuscate" list:
-keep class com.tencent.** { *;}


Using SDK Through C++ APIs (Optional)

If you prefer to use C++ APIs instead of Java for development, you can perform this step. If you only use Java to call the TRTC SDK, skip this step.
1. First, you need to integrate the TRTC SDK by importing JAR and SO libraries as instructed above.
2. Copy the C++ header file in the SDK to the project (path: SDK/LiteAVSDK_TRTC_xxx/libs/include) and configure the include folder path and dynamic link to the SO library in CMakeLists.txt.
cmake_minimum_required(VERSION 3.6)

# Configure the C++ API header file path
include_directories(
${CMAKE_CURRENT_SOURCE_DIR}/include # Copied from `SDK/LiteAVSDK_TRTC_xxx/libs/include`
)

add_library(
native-lib
SHARED
native-lib.cpp)

# Configure the path of the `libliteavsdk.so` dynamic library
add_library(libliteavsdk SHARED IMPORTED)
set_target_properties(libliteavsdk PROPERTIES IMPORTED_LOCATION ${CMAKE_CURRENT_SOURCE_DIR}/../../../libs/${ANDROID_ABI}/libliteavsdk.so)

find_library(
log-lib
log)

# Configure the dynamic link as `libliteavsdk.so`
target_link_libraries(
native-lib
libliteavsdk
${log-lib})
3. Use the namespace: The methods and types of cross-platform C++ APIs are all defined in the trtc namespace. To simplify your code, we recommend you use the trtc namespace.
using namespace trtc;
explain
For more information on how to configure the Android Studio C/C++ development environments, see Add C and C++ code to your project.
Currently, only the TRTC edition of the SDK supports C++ APIs. For more information on how to use C++ APIs, see Overview.