All Products
Search
Document Center

ApsaraVideo VOD:Integrate the SDK

Last Updated:Dec 05, 2025

This topic describes how to integrate the ApsaraVideo Player SDK for Android for short video playback scenarios that require only the player component. If you also need to create short videos, integrate the all-in-one SDK for Android. Otherwise, class duplication issues may occur and cause compilation to fail.

Environment requirements

  • Use the latest version of Android Studio. You can download it from Android Studio.

  • Operating system: Android 4.3 or later.

  • Device architecture: The device must use an armv7 or arm64 architecture.

  • The ApsaraVideo Player SDK for Android does not support emulators. You must run your application on a physical device after integration.

Prerequisites

  • You have registered for and obtained a license file for player authorization: AliVideoCert-********.crt. For more information, see Obtain a license.

  • If you plan to integrate the SDK locally, download the ApsaraVideo Player SDK for Android package. We recommend that you download the latest version.

Step 1: Integrate the SDK

Integrate using Gradle

Note

Make sure that your device is connected to the network and can access the Alibaba Cloud Maven repository.

  1. Add the Maven configuration.

    1. Integration with Gradle 7.x or later

      Configure the setting.gradle file of your project as follows:

      dependencyResolutionManagement {
          repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
          repositories {
              google()
              mavenCentral()
              jcenter() // jcenter() is about to be deprecated. We recommend that you gradually replace it with mavenCentral().
              maven { url "https://maven.aliyun.com/repository/releases" }
          }
      }
      dependencyResolutionManagement {
          repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
          repositories {
              google()
              mavenCentral()
              jcenter() // jcenter() is about to be deprecated. We recommend that you gradually replace it with mavenCentral().
              maven("https://maven.aliyun.com/repository/releases")
          }
      }
    2. Integration with Gradle versions earlier than 7.0

      Configure the build.gradle file of your project as follows:

      allprojects {
          repositories {
              google()
              mavenCentral()
              jcenter() // jcenter() is about to be deprecated. We recommend that you gradually replace it with mavenCentral().
              maven { url "https://maven.aliyun.com/repository/releases" }
          }
      }
      allprojects {
          repositories {
              google()
              mavenCentral()
              jcenter() // jcenter() is about to be deprecated. We recommend that you gradually replace it with mavenCentral().
              maven("https://maven.aliyun.com/repository/releases")
          }
      }
  2. Import the player SDK.

    Modify the build.gradle file of your app to add the player SDK to the dependencies node. The following example shows the configuration:

    Note

    Make sure that you specify the correct version number for the player SDK. Otherwise, an error is reported and the import fails. You can find the latest version number in Release notes of ApsaraVideo Player SDK for Android.

    dependencies {
        // AliPlayer SDK 
        implementation 'com.aliyun.sdk.android:AliyunPlayer:7.10.0-full'
    }
    dependencies {
        // AliPlayer SDK 
        implementation("com.aliyun.sdk.android:AliyunPlayer:7.9.0-full")
    }

Integrate locally

If you cannot download the player SDK package from the Maven repository due to a network issue, you can integrate the SDK locally.

Note

The following steps use Android Studio Flamingo | 2022.2.1 as an example. The procedure is similar for other versions of Android Studio.

  1. Copy the required AAR package to the libs folder of your project. If the libs folder does not exist, create it.

    图片

  2. Modify the build.gradle file in your project to add the flatDir setting to the repositories node in allprojects. The following example shows the configuration:

    flatDir {
       dirs 'libs'
    }
  3. Modify the build.gradle file of your app to add a reference to the AAR package in the dependencies node. The following example shows the configuration:

    dependencies {
          implementation fileTree(dir: 'libs', include the following: ['*.aar'])
    }

Integrate the RTS SDK (Optional)

To integrate the Real-Time Streaming (RTS) component, see Implement RTS stream pulling on Android.

Step 2: Configure the license

Important

If you use the global environment, which excludes the Chinese mainland, Hong Kong (China), and Macao (China), you must select one of the following methods to configure the environment for the Alibaba Cloud International Website (www.alibabacloud.com).

  1. Method 1: Call the following API operation to update the default configuration to the environment for the Alibaba Cloud International Website.

    // If you use the global environment, which excludes the Chinese mainland, Hong Kong (China), and Macao (China), make sure that you call the following API operation to update the default configuration to the environment for the Alibaba Cloud International Website before you call any player API operations. This ensures that all subsequent services run in the environment for the Alibaba Cloud International Website.
    // Set the environment for the Alibaba Cloud International Website using the unified AlivcBase interface. You cannot modify the environment at runtime.
    AlivcBase.getEnvironmentManager().setGlobalEnvironment(AlivcEnv.GlobalEnv.ENV_SEA);
  2. Method 2 (Recommended): For player SDK V7.6.0 or later, you can use the XML method to configure the environment for the Alibaba Cloud International Website.

    Add a <meta-data> node to the AndroidManifest.xml file.

    <meta-data
      android:name="com.aliyun.alivc_env"
      android:value="SEA"/>  

    The following example shows the configuration:1754556751170-7001527b-36a7-4ebd-8887-e0972a3d64e3

To add the license on an Android client, see Add a license on an Android client.

Step 3: Configure permissions

Declare all required permissions in the app/src/main/AndroidManifest.xml file:

<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />

Step 4: Configure obfuscation

Configure obfuscation in the proguard-rules.pro file. The following example shows the sample code:

-keep class com.alivc.**{*;}
-keep class com.aliyun.**{*;}
-keep class com.cicada.**{*;}


-dontwarn com.alivc.**
-dontwarn com.aliyun.**
-dontwarn com.cicada.**

Step 5: Enable logging (Optional)

Enabling logging helps you quickly locate and troubleshoot issues. It also provides data for performance optimization and user experience improvements. You can decide whether to enable logging based on your business scenarios. To obtain logs, see Obtain SDK logs.

// Enable logging.
Logger.getInstance(context).enableConsoleLog(true);
// Set the log level. The default level is AF_LOG_LEVEL_INFO. To troubleshoot issues, you can set the level to AF_LOG_LEVEL_TRACE.
Logger.getInstance(context).setLogLevel(Logger.LogLevel.AF_LOG_LEVEL_INFO);

Project structure

File name

Description

AliyunPlayer-x.x.x-full.aar

The complete AAR package that contains the FFmpeg dynamic library.

AliyunPlayer-x.x.x-part.aar

The AAR package that does not contain the FFmpeg dynamic library.

AlivcArtp-x.x.x.aar

Supports the ARTP protocol. This package is optional.

AlivcArtc-x.x.x.aar

Supports the ARTC protocol. This package is optional.

Note
  • If you do not integrate the short video SDK, you can add a direct dependency on the AliyunPlayer-x.xx.x-full.aar package.

  • If you integrate both the player SDK and the short video SDK, the player SDK depends on the AliyunPlayer-x.x.x-part package. You must also use a compatible FFmpeg version. This means you need to add a dependency on the com.aliyun.video.android:AlivcFFmpeg:x.x.x package.

  • If you use an incorrect SDK package during integration, an FFmpeg conflict occurs.

Common integration issues

For more information about common integration issues and their solutions, see FAQ about ApsaraVideo Player.