This topic describes how to integrate the short video SDK for Android using Maven.
Prerequisites
The following table describes the required development environment.
Category | Description |
System version | Supports Android 4.3 and later. |
Java version | Supports Java 1.7 and later. |
API level | Supports Android SDK API level 18 and later. |
Android Studio version | Supports Android Studio 2.3 and later. Download Android Studio. |
Integrate using Maven (Recommended)
Add the Alibaba Cloud Maven repository.
Add the Maven repository URL to the project-level build.gradle file.
allprojects { repositories { maven { url 'https://maven.aliyun.com/nexus/content/repositories/releases/' } } }Add the following dependencies to the build.gradle file in your app project directory.
ImportantIf you use the short video SDK V3.24.0 or later, you must use FFmpeg V4.3.0 or later.
Integration for V7.0.0 and later
dependencies{ implementation 'com.aliyun.aio:AliVCSDK_ShortVideo:7.10.0'// Required dependency for the short video SDK. implementation 'com.google.code.gson:gson:2.8.0'// Third-party dependency library. implementation 'com.aliyun.video.android:upload:1.6.7' // The upload library. This is optional if you do not need the upload feature. implementation 'com.aliyun.dpa:oss-android-sdk:+'// The short video upload feature requires the upload SDK and OSS. This is optional if you do not need the upload feature. }Integration for V6.21.0 and earlier
dependencies{ implementation 'com.aliyun.video.android:svideopro:6.21.0'// Integration for Professional Edition implementation 'com.aliyun.video.android:svideostandard:6.21.0'// Integration for Standard Edition implementation 'com.aliyun.video.android:svideosnap:6.1.0'// Integration for Basic Edition // Other dependencies implementation 'com.aliyun.video.android:AlivcFFmpeg:4.3.6' implementation 'com.google.code.gson:gson:2.8.0' // Third-party dependency library. }
The short video SDK currently provides .so files for only the armeabi-v7a and arm64-v8a instruction sets. If you need support for the armeabi instruction set, you can copy the .so file from the armeabi-v7a directory to the armeabi directory. Note: The short video SDK supports Android 4.3 and later. Therefore, compatibility with older ARMv5 and ARMv6 devices is not guaranteed.
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" />For Android 6.0 and later, you must request permissions dynamically.
Configure the license
After you obtain a license, configure the license file as follows. For more information about how to obtain a license, see Obtain a license for the short video SDK.
In the AndroidManifest.xml file, add two meta-data elements. For the first element, set the key name to com.aliyun.alivc_license.licensekey and the value to your LicenseKey. For the second element, set the key name to com.aliyun.alivc_license.licensefile and the value to the path to the built-in certificate file. The key names must be in all lowercase. The following code provides an example:
<application
android:icon="@drawable/icon"
android:label="@string/app_name" >
<meta-data
android:name="com.aliyun.alivc_license.licensekey"
android:value="yourLicenseKey"/> // Enter your LicenseKey.
<meta-data
android:name="com.aliyun.alivc_license.licensefile"
android:value="yourLicenseFile"/> // Enter the path of your built-in certificate file. Example: assets/alivc_license/AliVideoCert.crt
……
</application>Obfuscation configuration
You can configure obfuscation in the proguard-rules.pro file. The following code provides an example:
###################### Obfuscation configuration for the 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 the short video SDK and the player SDK for Android into your project, use the all-in-one SDK for Android. This prevents duplicate class issues that can cause compilation to fail.