Integrate ApsaraVideo MediaBox SDK for Android

Updated at: 2025-03-14 07:31

This topic describes how to integrate ApsaraVideo MediaBox SDK for Android.

Usage notes

For information about how to update ApsaraVideo MediaBox SDK V6.6.0 and earlier to V6.7.0 and later, see Updates on the integrated retouching effects of ApsaraVideo MediaBox SDK V6.7.0.

Environment requirements

Item

Description

Development tool

We recommend that you use Android Studio. To download Android Studio, visit the official website.

Android

Android 5.0 or later is supported.

Step 1: Integrate ApsaraVideo MediaBox SDK for Android

(Recommended) Integrate ApsaraVideo MediaBox SDK by using Maven dependencies
Manually integrate ApsaraVideo MediaBox SDK
  1. Add the URL of the Maven repository to the build.gradle file of the project.

    maven { url "https://maven.aliyun.com/nexus/content/repositories/releases" }
  2. Add the SDK dependency to the dependencies block in the build.gradle file of the app module.

    The following SDK version is used for reference only. For more information about how to obtain the latest SDK version of ApsaraVideo MediaBox SDK, see Download by scenario.

    // Integrate one of the following SDKs based on your business scenario.
    
    //1. All-in-one ApsaraVideo MediaBox SDK: supports ApsaraVideo Player, real-time streaming (RTS), standard live streaming, short video production, real-time communication (RTC) co-streaming, and basic retouching.
    implementation 'com.aliyun.aio:AliVCSDK_Standard:7.0.0'
    //2. ApsaraVideo MediaBox SDK for basic live streaming: supports ApsaraVideo Player, live stream ingest, basic retouching, and RTS.
    implementation 'com.aliyun.aio:AliVCSDK_BasicLive:7.0.0'
    //3. ApsaraVideo MediaBox SDK for short video scenarios: supports ApsaraVideo Player, short video production, and basic retouching.
    implementation 'com.aliyun.aio:AliVCSDK_UGC:7.0.0'
    //4. ApsaraVideo MediaBox SDK for interactive streaming: supports ApsaraVideo Player, RTS, live stream ingest, RTC co-streaming, and basic retouching.
    implementation 'com.aliyun.aio:AliVCSDK_InteractiveLive:7.0.0'
  1. Download an SDK for Android based on your business requirements. For more information, see Download by scenario.

  2. Copy the AAR file to the libs folder of the app module.

  3. In the build.gradle file of the project, add the flatDir setting to the repositories section of the allprojects block.

    flatDir {
       dirs 'libs'
    }
  4. Add the reference to the AAR file in the dependencies block of the build.gradle file of the app module.

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

Step 2: Configure a license for the SDK

The first time you access ApsaraVideo MediaBox SDK, you must apply for a license and bind the license to your application.

Step 3: Configure permissions

Configure the required permissions in the src/main/AndroidManifest.xml file of the app module.

<!-- Configure permissions for short video scenarios -->
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.FLASHLIGHT" />
<uses-permission android:name="android.permission.RECORD_VIDEO" />
<uses-permission android:name="android.permission.RECORD_AUDIO" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />

<! -- Configure permissions for live streaming scenarios -->
<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" />
<uses-permission android:name="android.permission.RECORD_AUDIO" /> <! -- Grant the permissions to use the recording feature -->
<uses-permission android:name="android.permission.CAMERA" /> <! -- Grant the permissions to use the camera feature -->
<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" />

Step 4: Configure obfuscation rules

Add obfuscation rules to the proguard-rules.pro file of the app module.

###################### Obfuscation configurations for ApsaraVideo Player SDK#########################
-keep class com.alivc.**{*;}
-keep class com.aliyun.**{*;}
-keep class com.cicada.**{*;}
-dontwarn com.alivc.**
-dontwarn com.aliyun.**
-dontwarn com.cicada.**

######################Obfuscation configurations for short video SDK#########################
-keep class com.aliyun.**{*;}
-keep class com.duanqu.**{*;}
-keep class com.qu.**{*;}
-keep class com.alibaba.**{*;}
-keep class component.alivc.**{*;}
-keep class com.alivc.**{*;}
-keep class org.webrtc.**{*;}
-keep class org.ugsv.**{*;}

######################Obfuscation configurations for Push SDK#########################
-keep class com.alivc.** { *;}
-keep class com.aliyun.rts.network.* { *;}
-keep class org.webrtc.ali.** {*;}
-keep class org.webrtc.utils.** {*;}

FAQ

See FAQ.

  • On this page (1, T)
  • Usage notes
  • Environment requirements
  • Step 1: Integrate ApsaraVideo MediaBox SDK for Android
  • Step 2: Configure a license for the SDK
  • Step 3: Configure permissions
  • Step 4: Configure obfuscation rules
  • FAQ
Feedback