This topic describes how to integrate Short Video SDK for Android using Maven.
Prerequisites
The following environment requirements must be met before development:
Category | Note: |
System Version | 4.3 or later. |
Java version | 1.7 or later. |
Android API level | Compatible with Android SDK API Level 18 or later. |
Android Studio version | 2.3 or later. Download Android Studio |
(Recommended) Integrate the SDK using Maven
Add the Alibaba Cloud Maven repository.
Add the URL of the Alibaba Cloud Maven repository to the build.gradle file of your project.
allprojects { repositories { maven { url 'https://maven.aliyun.com/nexus/content/repositories/releases/' } } }Add the following dependencies to the build.gradle file of the app module:
ImportantIf you want to use Short Video SDK V3.24.0 or later, make sure that AlivcFFmpeg V4.3.0 or later is used.
V7.0.0 or later
dependencies{ implementation 'com.aliyun.aio:AliVCSDK_ShortVideo:7.9.1'// Required. The dependency for the short video SDK. implementation 'com.google.code.gson:gson:2.8.0'// The third-party dependency library. implementation 'com.aliyun.video.android:upload:1.6.7' // Optional. The upload library. You can remove this dependency if you do not need the upload feature. implementation 'com.aliyun.dpa:oss-android-sdk:+'// Optional. The upload SDK and OSS are required for short video uploads. You can remove this dependency if you do not need the upload feature. }V6.21.0 or earlier
dependencies{ implementation 'com.aliyun.video.android:svideopro:6.21.0'// Required for Professional Edition implementation 'com.aliyun.video.android:svideostandard:6.21.0'// Required for Standard Edition implementation 'com.aliyun.video.android:svideosnap:6.1.0'// Required for Basic Edition // Other dependencies. implementation 'com.aliyun.video.android:AlivcFFmpeg:4.3.6' implementation 'com.google.code.gson:gson:2.8.0' // The third-party dependency. }
Short Video SDK currently only supports the armeabi-v7a and arm64-v8a instruction sets. If you require armeabi compatibility, we recommend that you copy the .so files of armeabi-v7a into the armeabi folder as a workaround. Given Android's evolution and Short Video SDK's minimum requirement of Android 4.3, supporting ARMv5 and ARMv6 is unnecessary, as these devices are obsolete.
Configure permissions
<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" />Dynamic permission requests are required for Android 6.0 or later.
Configure your license
After obtaining the license, you need to configure the license file. For information about how to acquire a license, see Obtain an SDK license.
In the AndroidManifest.xml file, add two <meta-data> entries: The first entry should have the com.aliyun.alivc_license.licensekey key (all lowercase), with the value set to your license key. The second entry should have the com.aliyun.alivc_license.licensefile key (all lowercase), with the value set to the path of the embedded license file. Sample code:
<application
android:icon="@drawable/icon"
android:label="@string/app_name" >
<meta-data
android:name="com.aliyun.alivc_license.licensekey"
android:value="yourLicenseKey"/> // Enter your license key.
<meta-data
android:name="com.aliyun.alivc_license.licensefile"
android:value="yourLicenseFile"/> // Enter the path to the embedded license file. Example: assets/alivc_license/AliVideoCert.crt.
...
</application>Configure obfuscation rules
You can configure obfuscation rules in the proguard-rules.pro file. Sample code:
######################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.**{*;}What to do next
Player integration
To integrate both Short Video SDK and Player SDK into your project, we recommend that you use ApsaraVideo MediaBox SDK for Android. This all-in-one solution prevents duplicate class errors and compilation failures.