This topic describes the environment requirements and integration methods of AliLive SDK for Android.

Prerequisites

Android Studio is installed. For more information about how to download Android Studio, visit the Android Studio page.

Environment requirements

Item Description
System version Android 5.0 or later.
Android API version API 21 or later.
CPU architecture ARM64 or ARMv7.

Procedure

  1. Integrate the SDK.
    • Method 1: Integrate the SDK by using Maven dependencies (Recommended)

      Add the following code to the dependencies block in the build.gradle file:

      implementation 'com.alivc.pusher:AlivcLivePusher:4.4.1'
      Note In this example, the version of AliLive SDK is used for your reference. For more information about how to download the latest AliLive SDK by using Maven dependencies, see SDK download and release notes.
    • Method 2: Integrate the SDK in manual mode
      1. Download and decompress the SDK package. For more information about the download links of the SDK package, see SDK download and release notes.
      2. Copy the files in the SDK directory to the libs directory of your project.
      3. Modify the dependencies block in the app/build.gradle file in your project.
        implementation fileTree(dir: 'libs', include: ['*.jar', '*.aar'])
        The app/build.gradle file
        Note If you want to add background music, you must use ApsaraVideo Player SDK, which is encapsulated in the AliyunPlayer.aar package.
  2. Add the following code to the src/main/AndroidManifest.xml file to configure the required permissions:
    <uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.REORDER_TASKS" />
    <uses-permission android:name="android.permission.VIBRATE" />
    // Configure the permissions to use the recording feature.
    <uses-permission android:name="android.permission.RECORD_AUDIO" />
    // Configure the permissions to use the camera.
    <uses-permission android:name="android.permission.CAMERA" />
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
    <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
    <uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
    <uses-permission android:name="android.permission.CHANGE_WIFI_STATE" />
    <uses-permission android:name="android.permission.WAKE_LOCK" />
    <uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS" />
    <uses-permission android:name="android.permission.READ_PHONE_STATE" />
    <uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
    <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
    <uses-permission android:name="android.permission.BLUETOOTH" />
    <uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW" />
  3. Add obfuscation rules to the proguard-rules.pro file.
    -keep class com.alivc.** { *;}

SDK usage notes