Anchor | Audience |
| |
settings.gradle.kts (or settings.gradle)
file: Add the jitpack repository dependency (to download the SVG animation library for playing gifts, SVGAPlayer):dependencyResolutionManagement { repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS) repositories { google() mavenCentral()// Add jitpack repository address maven { url = uri("https://jitpack.io") } } }
dependencyResolutionManagement { repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS) repositories { google() mavenCentral()// Add the jitpack repository URL maven { url 'https://jitpack.io' } } }
settings.gradle.kts (or settings.gradle)
file. It will import the tuilivekit component downloaded in Step 2 into your current project:include(":tuilivekit")
include ':tuilivekit'
build.gradle.kts (or build.gradle)
file and add the following code. It declares the dependency of the current app on the newly added tuilivekit component:api(project(":tuilivekit"))
api project(':tuilivekit')
TRTC SDK
, IM SDK
, tuiroomengine
, and the common library tuicore
. Developers do not need to configure them separately. To upgrade the version, modify the tuilivekit/build.gradle
file.proguard-rules.pro
file:-keep class com.tencent.** { *; }
AndroidManifest.xml
file and add tools:replace="android:allowBackup"
to the application node to override internal component settings with your own.// app/src/main/AndroidManifest.xml<application ...// Add the following configuration to override the settings in the dependent SDKandroid:allowBackup="false" tools:replace="android:allowBackup">
// log in to TUILogin.login(applicationContext, 1400000001, // Please replace with the SDKAppID obtained in step one "denny", // Please replace with your UserID "xxxxxxxxxxx", // You can calculate 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") } })
// Log inTUILogin.login(context,1400000001, // Please replace with the SDKAppID obtained in Step 1"denny", // Please replace with your UserID"xxxxxxxxxxx", // You can calculate a UserSig in the console and fill it in herenew TUICallback() {@Overridepublic void onSuccess() {Log.i(TAG, "login success");}@Overridepublic void onError(int errorCode, String errorMessage) {Log.e(TAG, "login failed, errorCode: " + errorCode + " msg:" + errorMessage);}});
Parameter | Type | Description |
SDKAppID | int | In the final step of step one, you have already obtained it, so it will not be repeated here. |
UserID | String | The ID of the current user, string type, is only allowed to contain letters (a-z and A-Z), numbers (0-9), hyphens, and underscores. |
userSig | String | Use the SecretKey obtained in Step One, Step 3 to encrypt information such as SDKAppID and UserID to obtain UserSig, which is a token for authentication used by Tencent Cloud to identify whether the current user can use TRTC services. You can generate a temporarily usable UserSig through the Auxiliary Tools in the console. For more information, see UserSig. |
GenerateTestUserSig.genTestSig
function to generate UserSig. In this method, the SDKSecretKey is vulnerable to decompilation and reverse engineering. If your key is leaked, attackers can steal your Tencent Cloud traffic.import com.trtc.uikit.livekit.VoiceRoomKit;VoiceRoomKit.createInstance(applicationContext).createRoom("roomId", VoiceRoomDefine.CreateRoomParams())
import com.trtc.uikit.livekit.VoiceRoomKit;VoiceRoomKit.createInstance(getApplicationContext()).createRoom("roomId", new VoiceRoomDefine.CreateRoomParams());
Voice chat room preview screen | Voice chat room in-room screen |
| |
import com.trtc.uikit.livekit.VoiceRoomKit;VoiceRoomKit.createInstance(applicationContext).enterRoom("roomId")
import com.trtc.uikit.livekit.VoiceRoomKit;VoiceRoomKit.createInstance(getApplicationContext()).enterRoom("roomId");
Voice Chat Room | Voice Chat Room |
| |
Was this page helpful?