Integrate Queen SDK for Android

更新时间:
复制 MD 格式

Queen SDK is a retouching SDK by Alibaba Cloud that supports image retouching, face retouching, chroma key, stickers, makeup, gesture recognition, body shaping, hairdressing, and augmented reality (AR) writing for live streaming, video conferencing, and short video scenarios. Integrate Queen SDK for Android to add beauty effects to your app.

Prerequisites

Your development environment meets the following requirements:

Item

Description

Android

Android 4.3 or later.

Java

Java 1.7 or later.

API LEVEL

Android API level 18 or later.

Android Studio

Android Studio 2.3 or later.

Integration guide

(Recommended) Maven integration

  1. Add the Alibaba Cloud Maven repository to your project-level build.gradle.

    allprojects {
        repositories {
            google()
            jcenter()
            maven { url "https://maven.aliyun.com/repository/releases" }
        }
    }
  2. Add Queen SDK dependencies to your app-level build.gradle.

    // The Queen SDK package.
    implementation "com.aliyun.maliang.android:queen:6.8.1-official-pro"
    
    // Optional. The menu component of Queen SDK.
    implementation "com.aliyun.maliang.android:queen_menu:6.8.1-official-pro-tiny"   // Download the menu resources.
    implementation "com.aliyun.maliang.android:queen_menu:6.8.1-official-pro"        // Package the menu resources on your on-premises machine.
Note

Queen SDK and other Alibaba Cloud SDKs such as RTC SDK may contain duplicate native libraries, causing packaging failures. If conflicts occur, add packagingOptions to your build.gradle:

android {    
  ...
  compileSdkVersion ... 
  ...
  packagingOptions {
        pickFirst '**/libMNN.so'    // If duplicate libMNN.so files exist, add this line of code.
        pickFirst '**/libMNN_CL.so'    // If duplicate libMNN_CL.so files exist, add this line of code.
        pickFirst '**/libc++_shared.so' // If duplicate libc++_shared.so files exist, add this line of code.
    }
  ...
}

Manual integration

  1. Download and decompress the Queen SDK package.

  2. Copy the .aar files extracted from the SDK package to the libs folder of your project.

  3. Add AAR package dependencies with Gradle.

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

     dependencies {
      implementation files('libs/alivc-livepusher-lib-release.aar')
    }
  5. Click Sync Now to compile the project.

Configure permissions

Add the following permissions to your AndroidManifest.xml:

<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<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" />

On Android 6.0 and later, request permissions at runtime:

if (ActivityCompat.checkSelfPermission(this, Manifest.permission.CAMERA)
                == PackageManager.PERMISSION_GRANTED) {
    // You have obtained the permission.
    //...
} else {
    // You do not have this permission. Apply for it.
    // PERMISSION_REQUEST_CODE specifies the code of the application for the permission. You can set the code to an arbitrary number.
    ActivityCompat.requestPermissions(this, new String[]{Manifest.permission.CAMERA}, PERMISSION_REQUEST_CODE);
}

Configure the license

Obtain a Queen SDK license before you proceed. Then configure the license key and license file in your project:

Note
  • The Queen SDK for ApsaraVideo Live and the short video SDK for ApsaraVideo VOD share the same license. Configure it only once, using the latest license file.

  • If your SDK is updated or renewed, update the license:

    1. Obtain the latest license.

    2. Configure the new license in your project.

Import the license to your project's assets folder, then add two meta-data entries under the application node in AndroidManifest.xml:

com.aliyun.alivc_license.licensekey specifies the license key.

<application
 android:icon="@drawable/icon"
 android:label="@string/app_name" >
 <meta-data
 android:name="com.aliyun.alivc_license.licensekey" 
 android:value="Your LicenseKey"/> // Enter the license key that you obtain.
 <meta-data
 android:name="com.aliyun.alivc_license.licensefile"
 android:value="Your LicenseFile Path"/> // Enter the path of the license file relative to the assets folder. Example: alivc_license/AliVideoCert.crt.
 ...
</application>

References

Item

References

Sample project

Sample project

Contains complete SDK integration code and demo image resources.

Quick start

Quick start package

Step-by-step integration instructions and troubleshooting guidance for Queen SDK.

Third-party SDK integration