Integrate the Short Video SDK for Android by using Maven.
Prerequisites
Your development environment must meet these requirements:
|
Item |
Requirement |
|
Android version |
4.3 or later. |
|
Java version |
1.7 or later. |
|
Android API level |
18 or later. |
|
Android Studio version |
2.3 or later. Download Android Studio |
Integrate the SDK by using Maven (recommended)
-
Add the Alibaba Cloud Maven repository.
Add the Alibaba Cloud Maven repository URL to your project's build.gradle file.
allprojects { repositories { maven { url 'https://maven.aliyun.com/nexus/content/repositories/releases/' } } } -
Add dependencies to the build.gradle file of your app module:
ImportantShort Video SDK V3.24.0 and later requires AlivcFFmpeg V4.3.0 or later.
V7.0.0 or later
dependencies{ implementation 'com.aliyun.aio:AliVCSDK_ShortVideo:7.11.0'// Required dependency for the Short Video SDK. implementation 'com.google.code.gson:gson:2.8.0'// Third-party dependency. implementation 'com.aliyun.video.android:upload:1.6.7' // Optional: The upload library. You can omit this if you do not need the upload feature. implementation 'com.aliyun.dpa:oss-android-sdk:+'// Optional: The upload SDK and OSS are required for video uploads. You can omit 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 supports only armeabi-v7a and arm64-v8a. For armeabi compatibility, copy the armeabi-v7a .so files into the armeabi folder. ARMv5 and ARMv6 devices are obsolete and not supported.
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" />
Android 6.0 and later requires dynamic permission requests.
Configure your license
Configure your license file after you obtain one. Obtain a license for the short video SDK.
Add two <meta-data> elements to your AndroidManifest.xml: com.aliyun.alivc_license.licensekey for the license key and com.aliyun.alivc_license.licensefile for the license file path.
<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
Add obfuscation rules to the proguard-rules.pro file:
######################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, use ApsaraVideo MediaBox SDK for Android to avoid duplicate class errors and compilation failures.