All Products
Search
Document Center

ApsaraVideo VOD:Quick integration of Android Player SDK

Last Updated:Jun 06, 2025

If you want to implement features such as micro-drama scenarios and only need the player component, you can refer to this topic to learn about the integration solution for the Android Player SDK. If you also need to create short videos, we recommend that you use ApsaraVideo MediaBox SDK for Android for integration. Otherwise, duplicate class errors may occur, resulting in compilation failures.

Environment requirements

  • We recommend that you use the latest version of Android Studio. You can download it at Android Studio.

  • System version: Android 4.3 and later versions are supported.

  • ABI compatibility: The device architecture must be armv7 or arm64.

  • The Android Player SDK does not support emulators. After integration, you must run it on a physical device.

Prerequisites

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

  • When integrating the SDK locally, you need to first download the Android Player SDK package (which includes the player SDK and demo source code). Starting from version V5.4.6.0, the Android Player SDK provides demos that support AndroidX and demos that do not support AndroidX. Please choose the appropriate download based on your project requirements. We recommend that you download the latest version.

SDK integration

Gradle integration

Note

Make sure that the network is accessible and that you can access the Alibaba Cloud Maven repository.

  1. Add the Alibaba Cloud Maven repository URL to the build.gradle file of the project. Sample code:

    maven { url "https://maven.aliyun.com/repository/releases" }

    The following figure shows the result of the preceding operation:2024-07-17_165101.png

  2. Modify the build.gradle file of the application and add the player SDK to the dependencies block. Sample code:

    Note

    Make sure that the version number of the player SDK is correct. Otherwise, an error will be reported and the dependencies will fail to be added. You can check the player SDK versions in Release history of Android Player SDK.

    def player_sdk_version = "7.2.0" // The latest version of the player SDK
    // Player SDK
    implementation "com.aliyun.sdk.android:AliyunPlayer:$player_sdk_version-full"

    The following figure shows the result of the preceding operation:

    1743646842166-d8c80472-a2d9-4f23-bf34-ff00b92ab1c9-2

If you need to integrate the RTS ultra-low-latency live streaming component into the player, see Implement RTS stream pulling on Android.

Local integration

If you cannot download the player SDK package from the Maven repository due to network issues, we recommend that you integrate the SDK locally.

Note

The following section describes how to use Android Studio Flamingo | 2022.2.1 to integrate the SDK. You can also follow similar procedures when using other development tools.

  1. Copy the required AAR packages to the libs directory of your project (if the libs folder does not exist, create it manually).

    图片

  2. Modify the build.gradle file of the project and add the flatDir setting to the repositories section of the allprojects block. Sample code:

    flatDir {
       dirs 'libs'
    }
  3. Modify the build.gradle file of the application and add references to the AAR and Conan packages in the dependencies block. Sample code:

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

    Add the following obfuscation rules to the Proguard-rules.pro file of the application. Sample code:

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

Bind a license to an Android application

  1. Configure a license.

    1. Recommended. Copy the license file to the assets directory of your Android Studio project.

      Note

      You can also copy the license file to another directory on your device. If you do so, make sure that the value that corresponds to com.aliyun.alivc_license.licensefile for the China environment or com.aliyun.alivc_license.licensefile_SEA for the international environment is the same as the path of the license file.

    2. Add <meta-data> elements to the AndroidManifest.xml file.

      Important
      • If the authentication fails after you configure the license, check whether the <meta-data> elements are added under the <application> element, and whether the names in the <meta-data> elements are correct. If the issue persists, troubleshoot the issue by referring to License FAQ.

      • To use Player SDK V6.14.0 or later on the Alibaba Cloud international site (alibabacloud.com), you must configure a license specifically for the international environment. If Player SDK is not used, you can configure a license for the China environment.

      • You can bind two licenses to your application at the same time: one for the China environment and the other for the international environment. When starting your application, you can specify which environment the player should use by configuring the service environment for Player SDK. The environment cannot be changed while the player is running.

      License配置-android-EN3.png

      // Configure a license for the China environment. This is the default configuration.
      <meta-data
          android:name="com.aliyun.alivc_license.licensekey"
          android:value="foIVziMaUHaRqgDyhf6b6eb8fcf014af39535d0720a32****"/>  <!-- TODO: Specify the license key.-->
      <meta-data
          android:name="com.aliyun.alivc_license.licensefile"
          android:value="assets/cert/release.crt"/>  <!-- TODO: Specify the path of your license file.-->
      
      
      // Configure a license for the international environment and manually add _SEA to the end.
      <meta-data
          android:name="com.aliyun.alivc_license.licensekey_SEA"
          android:value="f6b6foIVziMaUHaRqgDyheb8fcf014af39535d0a32720****"/>  <!-- TODO: Specify the license key.-->
      <meta-data
          android:name="com.aliyun.alivc_license.licensefile_SEA"
          android:value="assets/cert/release.crt"/>  <!-- TODO: Specify the path of your license file.-->
  2. Configure a service environment for Player SDK if you want to use the international environment.

    Beginning with Player SDK V6.14.0, you can select a service environment, with the default configuration set to the China environment. To switch to the international environment, you must update the service environment to international using the provided method each time you start your application. Failure to do so will result in authentication failures for the license that authorizes your application to use Player SDK. This step is unnecessary if you are using Player SDK versions earlier than V6.14.0 or other SDKs.

    // Before using the international environment, make sure that you have updated the service environment to international prior to calling any player API operations. This ensures that all subsequent services will run on the Alibaba Cloud international site (alibabacloud.com).
    // Update the service environment to international by calling the following operation. The environment cannot be changed while the player is running.
    AlivcBase.getEnvironmentManager().setGlobalEnvironment(AlivcEnv.GlobalEnv.ENV_SEA);

Project structure

File

Description

AliyunPlayer-x.x.x-full.aar

A complete AAR package that contains FFmpeg dynamic frameworks.

AliyunPlayer-x.x.x-part.aar

An AAR package that does not contain FFmpeg dynamic frameworks.

AlivcArtp-x.x.x.aar

An AAR package that supports the Alibaba Real-time Transport Protocol (ARTP) protocol. This package is optional.

AlivcArtc-x.x.x.aar

An AAR package that supports the Alibaba Real-Time Communication (ARTC) protocol. This package is optional.

Note
  • If you do not integrate the short video SDK, add the AliyunPlayer-x.xx.x-full.aar dependency to your project.

  • If you want to integrate both the short video SDK and the player SDK, you must add the AliyunPlayer-x.x.x-part.aar dependency for the player SDK and the com.aliyun.video.android:AlivcFFmpeg:x.x.x dependency for both the player SDK and the short video SDK.

  • If you include an invalid dependency when you integrate the SDK, an FFmpeg conflict may occur.

FAQ

For more information about issues that may occur when using the player and their solutions, see FAQ about the player.