.aar
files prepared above to the libs
directory of the app project.assets/
of your SDK package to the ../src/main/assets
directory. If there are files in the MotionRes
folder of your SDK package, also copy them to the ../src/main/assets
directory.jniLibs
folder to the ../src/main/jniLibs
directory of the project.build.gradle
of the app module to add a dependency reference:android{...defaultConfig {applicationId "Replace it with the package name bound to the `lic`"....}packagingOptions{pickFirst '**/libc++_shared.so'}}dependencies {...compile fileTree(dir: 'libs', include: ['*.jar','*.aar'])// Add `*.aar`}
dependencies{implementation 'com.google.code.gson:gson:2.8.2'// Version 2.6.0 and subsequent versions require additionimplementation 'androidx.exifinterface:exifinterface:1.3.3'//Version 3.5.0 and subsequent versions require additionimplementation 'com.tencent.tav:libpag:4.3.33-noffavc'}
assets
, so
, and MotionRes
assets
resources, so
library, and animated effect resources MotionRes
(unavailable in some basic edition SDKs) required by the SDK online. After successful download, set the paths of the above files in the SDK.dependencies
.dependencies {// For example, the S1-04 edition is as follows:implementation 'com.tencent.mediacloud:TencentEffect_S1-04:version name'//The version name can be found on the 'Version History' page of the official website, for example, 3.0.0.13.//Alternatively, you can use 'latest.release', but please note that this will always keep your SDK up to date, which may not meet your expectations for some versions with significant changes. Please use 'latest.release' with caution.}
defaultConfig
, specify the CPU architecture to be used by your application.defaultConfig {ndk {abiFilters "armeabi-v7a", "arm64-v8a"}}
armeabi-v7a
and arm64-v8a
.../assets/MotionRes
.../assets/lut
.Edition | Maven Address |
A1 - 01 | implementation 'com.tencent.mediacloud:TencentEffect_A1-01:version name' |
A1 - 02 | implementation 'com.tencent.mediacloud:TencentEffect_A1-02:version name' |
A1 - 03 | implementation 'com.tencent.mediacloud:TencentEffect_A1-03:version name' |
A1 - 04 | implementation 'com.tencent.mediacloud:TencentEffect_A1-04:version name' |
A1 - 05 | implementation 'com.tencent.mediacloud:TencentEffect_A1-05:version name' |
A1 - 06 | implementation 'com.tencent.mediacloud:TencentEffect_A1-06:version name' |
S1 - 00 | implementation 'com.tencent.mediacloud:TencentEffect_S1-00:version name' |
S1 - 01 | implementation 'com.tencent.mediacloud:TencentEffect_S1-01:version name' |
S1 - 02 | implementation 'com.tencent.mediacloud:TencentEffect_S1-02:version name' |
S1 - 03 | implementation 'com.tencent.mediacloud:TencentEffect_S1-03:version name' |
S1 - 04 | implementation 'com.tencent.mediacloud:TencentEffect_S1-04:version name' |
License URL
and License KEY
as instructed in License Guide.assets
directory. However, if your app needs to use the SDK features without ever connecting to the internet, you can download the license file and put it in the assets
directory. In this case, the license file must be named v_cube.license
.URL
and KEY
to trigger the license download. Do not download it just before use. You can also trigger the download in the onCreate
method of the Application
, but this is not recommended as the download is very likely to fail if there is no network permission or if a network disconnection occurs.// If you just want to trigger the download or update the license but don't care about the authentication result, you can pass in `null` for the fourth parameter.TELicenseCheck.getInstance().setXMagicLicense(context, URL, KEY, null);
TEMenuActivity.java
of the demo):// If your `so` library is downloaded from the internet, set the `so` path before calling `TELicenseCheck.getInstance().setTELicense`; otherwise, authentication will fail.// XmagicApi.setLibPathAndLoad(validLibsDirectory);// If your `so` library is built into the APK package, you don't need to call the above method.TELicenseCheck.getInstance().setTELicense(context, URL, KEY, new TELicenseCheckListener() {@Overridepublic void onLicenseCheckFinish(int errorCode, String msg) {// Note: this callback is not necessarily in the call threadif (errorCode == TELicenseCheck.ERROR_OK) {// Authentication succeeded} else {// Authentication failed}}});
errorCode
description:Error Code | Description |
0 | Success. |
-1 | The input parameter is invalid; for example, the URL or KEY is empty. |
-3 | Download failed. Check the network settings. |
-4 | Unable to obtain any Tencent Effect authentication information from the local system, which may be caused by an I/O failure. |
-5 | The VCUBE TEMP license file is empty, which may be caused by an I/O failure. |
-6 | The JSON field in the v_cube.license file is incorrect. Contact Tencent Cloud for assistance. |
-7 | Signature verification failed. Contact Tencent Cloud for assistance. |
-8 | Decryption failed. Contact Tencent Cloud for assistance. |
-9 | The JSON field in TELicense is incorrect. Contact Tencent Cloud for assistance. |
-10 | The Tencent Effect SDK authorization information parsed online is empty. Contact Tencent Cloud for assistance. |
-11 | Failed to write the Tencent Effect SDK authorization information to the local file, which may be caused by an I/O failure. |
-12 | Download failed, and failed to parse local assets. |
-13 | Authentication failed. Check whether the so file is in the package or the so path has been set correctly. |
3004/3005 | The authorization is invalid. Contact Tencent Cloud for assistance. |
3015 | Bundle ID and Package Name mismatch. Check whether the Bundle ID or Package Name used by your app are the same as the ones you applied for and whether the correct license file is used. |
3018 | The license file has expired and needs to be renewed. |
Others | Contact Tencent Cloud for assistance. |
assets
directory, you need to copy them to the app's private directory before use. You can copy them in advance or in the callback of successful authentication in the previous step. The sample code is in the TEMenuActivity.java
of the demo.// Assign `resPathSetting` to the `mResPath` variable in the following `copyRes` methodString resPath = new File(getFilesDir(), AppConfig.getInstance().getBeautyFileDirName()).getAbsolutePath();// Copy resource files to the private directory. It must be performed just once// Invocation should be executed in a child threadpublic static boolean copyRes(Context context) {if (TextUtils.isEmpty(mResPath)) {throw new IllegalStateException("resource path not set, call XmagicResParser.setResPath() first.");}int addResult = XmagicApi.addAiModeFilesFromAssets(context, mResPath);LogUtils.e(TAG, "add ai model files result = " + addResult);String lutDirName = "lut";boolean result = FileUtil.copyAssets(context, lutDirName, mResPath + "light_material" + File.separator + lutDirName);String motionResDirName = "MotionRes";boolean result2 = FileUtil.copyAssets(context, motionResDirName, mResPath + motionResDirName);return result && result2;}
TEMenuActivity.java
of the demo.mXmagicApi = new XmagicApi(this, local path of downloaded resource files,new XmagicApi.OnXmagicPropertyErrorListener());
com.tencent.effect.beautykit.provider
package).GLCameraView
in the demo to the preview layout.<com.tencent.demo.camera.camerax.GLCameraXViewandroid:id="@+id/te_camera_layout_camerax_view"android:layout_width="match_parent"android:layout_height="match_parent"app:back_camera="false"app:surface_view="false"app:transparent="true" />
com.tencent.demo.camera
directory from the demo project to the project. Use the GLCameraXView
class to quickly implement the camera feature. For more information, see TECameraActivity.java
of the demo project.@Overridepublic int onCustomProcessTexture(int textureId, int textureWidth, int textureHeight) {int resultTextureId = 0;if (!isUseTencentEffect) {resultTextureId = textureId;} else {resultTextureId = mXmagicApi.process(textureId, textureWidth, textureHeight);}return resultTextureId;}
onResume()
method of Activity
.//resPath is the path set in the first step of the second stage.mXmagicApi = new XmagicApi(this, resPath,new XmagicApi.OnXmagicPropertyErrorListener());
Parameters | Description |
Context context | Context |
String resDir | |
OnXmagicPropertyErrorListener errorListener | Callback function implementation class. |
mXmagicApi.setTipsListener(new XmagicTipsListener() {final XmagicToast mToast = new XmagicToast();@Overridepublic void tipsNeedShow(String tips, String tipsIcon, int type, int duration) {mToast.show(MainActivity.this, tips, duration);}@Overridepublic void tipsNeedHide(String tips, String tipsIcon, int type) {mToast.dismiss();}});
int outTexture = mXmagicApi.process(textureId, textureWidth, textureHeight);
//Use this method for the 3.5.0 version and latermXmagicApi.setEffect(String effectName, int effectValue, String resourcePath, Map<String, String> extraInfo)// Available attributes of the input parameters can be obtained from `XmagicResParser.parseRes()`// Use this method for version 3.3.0 and earliermXmagicApi.updateProperty(XmagicProperty<?> p);
Activity
's onResume()
method.// Restore the sound effects in the beauty, some material contain sound effectsmXmagicApi.onResume();
onPause()
method in Activity.// Pause the sound of the material, regardless of whether the material contains audio effectsmXmagicApi.onPause();
GL thread
.// Note that this method needs to be called in the GL threadmXmagicApi.onDestroy()
minifyEnabled
to true
) when printing the release
package, some code that is not called at the Java layer will be trimmed out and may be called at the native layer, causing a no xxx method
exception.keep
rules to prevent Xmagic code from being trimmed out:-keep class com.tencent.xmagic.** { *;}-keep class org.light.** { *;}-keep class org.libpag.** { *;}-keep class org.extra.** { *;}-keep class com.gyailib.**{ *;}-keep class com.tencent.cloud.iai.lib.** { *;}-keep class com.tencent.beacon.** { *;}-keep class com.tencent.qimei.** { *;}-keep class androidx.exifinterface.** { *;}
File Type | Description | ||
assets | audio2exp | | Avatar: A virtual human voice-driven model. If you do not use this feature, you do not need this model. |
| benchmark | | Device compatibility usage. |
| Light3DPlugin | | Usage of 3D stickers. |
| LightBodyPlugin | LightBody3DModel.bundle | Usage of 3D skeletal points for human body. |
| | LightBodyModel.bundle | Usage of body shaping feature. |
| LightCore | | SDK core model resources. |
| LightHandPlugin | | Usage of gesture stickers and hand tracking capabilities. |
| LightSegmentPlugin | | Usage of background segmentation capabilities. |
| lut | | Free filter resources. |
demo_xxx_android_xxxx | | | Demo project. |
jniLibs | libace_zplan.so | | 3D engine library. |
| libaudio2exp.so | | Avatar virtual human voice driver library. If this feature is not being used, then this library is not necessary. |
| libc++_shared.so | | libc++_shared.so is a shared library for the C++ standard library, which provides a set of functions and classes to support the development and execution of C++ programs. It is widely used in the Android system and is an important component of C++ applications and libraries. If your project already has a C++ shared library, you can keep only one copy. |
| liblight-sdk.so | | Light SDK core library. |
| libpag.so | | Animation file library that Light SDK depends on. |
| libtecodec.so | | Encoding and decoding library that Light SDK depends on. |
| libv8jni.so | | Library used for parsing JavaScript that Light SDK depends on. |
| libYTCommonXMagic.so | | license authentication usage |
libs | xmagic-xxxx.aar | | AAR file of beauty SDK |
MotionRes | 2dMotionRes | | Sticker 2D |
| 3dMotionRes | | Sticker 3D |
| avatarRes | | Avatar Resource |
| ganMotionRes | | Sticker gan |
| handMotionRes | | Sticker hand |
| makeupRes | | Makeup res |
| segmentMotionRes | | Background segmentation res |
unity | aar | | Bridge AAR required for Unity project |
| module | | Original project of the bridge AAR |
Was this page helpful?