Last updated: 2021-09-13 15:44:39

    This document describes how to quickly integrate Tencent Cloud LiteAVSDK for Android into your project.

    Environment Requirements

    • Android Studio 2.0 or above
    • Android 4.1 (SDK API level 16) or above

    Integrating the SDK (AAR)

    You can use Gradle to automatically load the AAR file or manually download the AAR file and import it into your project.

    Method 1: automatic loading (AAR)

    Since JCenter has been deprecated, you can configure a Maven Central repository in Gradle to automatically download and update LiteAVSDK.
    Open your project with Android Studio and modify the build.gradle file as described below to complete the integration.

    1. Open build.gradle under your application.
    2. Add the LiteAVSDK dependency to dependencies.
      dependencies {
      implementation 'com.tencent.liteav:LiteAVSDK_Professional:latest.release'
      }
      Or
      dependencies {
      implementation 'com.tencent.liteav:LiteAVSDK_Professional:latest.release@aar'
      }
    3. In defaultConfig, specify the CPU architecture to be used by the application. Currently, LiteAVSDK supports armeabi, armeabi-v7a, and arm64-v8a.
      defaultConfig {
      ndk {
      abiFilters "armeabi", "armeabi-v7a", "arm64-v8a"
      }
      }
    4. Click the Sync Now button to sync the SDK. If you have no problem accessing Maven Central, the SDK will be downloaded and integrated into your project automatically.

    Method 2: manual download (AAR)

    If you have problem accessing Maven Central, you can manually download the SDK and integrate it into your project.

    1. Download LiveAVSDK and decompress the file.
    2. Copy the AAR file in the SDK directory 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 the LiteAVSDK dependency and, in app/build.gradle, add code that references the AAR file.
      implementation(name:'LiteAVSDK_Professional_8.7.10102', ext:'aar')
      
    5. In defaultConfig of app/build.gradle, specify the CPU architecture to be used by the application. Currently, LiteAVSDK supports armeabi, armeabi-v7a, and arm64-v8a.
      defaultConfig {
          ndk {
              abiFilters "armeabi", "armeabi-v7a", "arm64-v8a"
          }
      }
      
    6. Click Sync Now to complete the integration of LiteAVSDK.

    Integrating the SDK (JAR)

    If you do not want to import the AAR library, you can also integrate LiteAVSDK by importing JAR and SO libraries.

    1. Download LiveAVSDK and decompress the file. In the SDK directory, find LiteAVSDK_Professional_xxx.zip (xxx indicates the version number of LiteAVSDK).

      Decompress the file, and you will find a libs directory that contains a JAR file and several SO folders, as shown below:
    2. Copy the JAR file and armeabi, armeabi-v7a, and arm64-v8a folders to the app/libs directory.
    3. Add code that references the JAR library in app/build.gradle.
      dependencies {
      implementation fileTree(dir:'libs',include:['*.jar'])
      }
    4. Add flatDir to build.gradle under the project’s root directory to specify the local path for the repository.
    5. In app/build.gradle, add code that references the SO libraries.
    6. In defaultConfig of app/build.gradle, specify the CPU architecture to be used by the application. Currently, LiteAVSDK supports armeabi, armeabi-v7a, and arm64-v8a.
      defaultConfig {
      ndk {
      abiFilters "armeabi", "armeabi-v7a", "arm64-v8a"
      }
      }
    7. Click Sync Now to complete the integration.

    Setting Packaging Parameters

    packagingOptions {
    pickFirst '**/libc++_shared.so'
    doNotStrip "*/armeabi/libYTCommon.so"
    doNotStrip "*/armeabi-v7a/libYTCommon.so"
    doNotStrip "*/x86/libYTCommon.so"
    doNotStrip "*/arm64-v8a/libYTCommon.so"
    }

    Configuring Permissions

    Configure permissions for your application in AndroidManifest.xml. LiteAVSDK needs 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.WRITE_EXTERNAL_STORAGE" />
    <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
    <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-permission android:name="android.permission.READ_PHONE_STATE" />
    <uses-feature android:name="android.hardware.Camera"/>
    <uses-feature android:name="android.hardware.camera.autofocus" />
    

    Configuring License

    Click Get License to obtain a trial license. You will get two strings: a license URL and a decryption key.

    Before you use the features of MLVB Enterprise Edition in your application, complete the following configurations (preferably in the application class).

    public class MApplication extends Application {

    @Override
    public void onCreate() {
    super.onCreate();
    String licenceURL = ""; // The license URL obtained
    String licenceKey = ""; // The license key obtained
    TXLiveBase.getInstance().setLicence(this, licenceURL, licenceKey);
    }
    }

    Configuring Obfuscation Rules

    In the proguard-rules.pro file, add LiteAVSDK classes to the "do not obfuscate" list.

    -keep class com.tencent.** { *;}