dependencies {//For example, the S1-04 package is as follows:implementation 'com.tencent.mediacloud:TencentEffect_S1-04:version number'//The version number can be found on the Version History page on the official website, e.g., 3.0.0.13. You can also use latest.release for the version number.//But please note: using latest.release will always keep your SDK version up to date, which might not meet your expectations for versions with major changes. Use latest.release with caution.
defaultConfig {ndk {abiFilters "armeabi-v7a", "arm64-v8a"}}
Version | Maven Address |
A1 - 01 | implementation 'com.tencent.mediacloud:TencentEffect_A1-01:version number' |
A1 - 02 | implementation 'com.tencent.mediacloud:TencentEffect_A1-02:version number' |
A1 - 03 | implementation 'com.tencent.mediacloud:TencentEffect_A1-03:version number' |
A1 - 04 | implementation 'com.tencent.mediacloud:TencentEffect_A1-04:version number' |
A1 - 05 | implementation 'com.tencent.mediacloud:TencentEffect_A1-05:version number' |
A1 - 06 | implementation 'com.tencent.mediacloud:TencentEffect_A1-06:version number' |
S1 - 00 | implementation 'com.tencent.mediacloud:TencentEffect_S1-00:version number' |
S1 - 01 | implementation 'com.tencent.mediacloud:TencentEffect_S1-01:version number' |
S1 - 02 | implementation 'com.tencent.mediacloud:TencentEffect_S1-02:version number' |
S1 - 03 | implementation 'com.tencent.mediacloud:TencentEffect_S1-03:version number' |
S1 - 04 | implementation 'com.tencent.mediacloud:TencentEffect_S1-04:version number' |
S1 - 05 | implementation 'com.tencent.mediacloud:TencentEffect_S1-05:version number' |
S1 - 06 | implementation 'com.tencent.mediacloud:TencentEffect_S1-06:version number' |
S1 - 07 | implementation 'com.tencent.mediacloud:TencentEffect_S1-07:version number' |
xmagic-xxxx.aar
file from the SDK
folder to your project's libs
directory.build.gradle
and add the dependency reference:android{...defaultConfig {applicationId "Modify it with the package name bound to the authorized license."....}packagingOptions {pickFirst '**/libc++_shared.so'}}dependencies{...compile fileTree(dir: 'libs', include: ['*.jar','*.aar'])//add *.aar}Note:
dependencies{implementation 'com.google.code.gson:gson:2.8.2'//Needs to be added for v2.6.0 to 3.1.0.2.implementation 'androidx.exifinterface:exifinterface:1.3.3'//Needs to be added for v3.5.0 or later versions.implementation 'com.tencent.tav:libpag:4.3.33-noffavc'}
../assets/MotionRes
../assets/lut
//If you only want to trigger the download or update the license without caring about the authentication result, input null for the fourth parameter.TELicenseCheck.getInstance().setXMagicLicense(context, URL, KEY, null);
TELicenseCheck.getInstance().setTELicense(context, URL, KEY, new TELicenseCheckListener() {@Overridepublic void onLicenseCheckFinish(int errorCode, String msg) {//Note: This callback may not be on the calling thread.if (errorCode == TELicenseCheck.ERROR_OK) {// Authentication succeeded.} else {// Authentication failed.}}});
Error Code | Description |
0 | Success |
-1 | Invalid input parameters, such as empty URL or KEY |
-3 | Download failure. Please check your network settings. |
-4 | TE authorization information read locally is empty, possibly due to I/O failure. |
-5 | Content of the VCUBE TEMP license file is empty, possibly due to I/O failure. |
-6 | JSON fields in the v_cube.license file are incorrect. Please contact the Tencent Cloud team to deal with it. |
-7 | Signature verification failed. Please contact the Tencent Cloud team to deal with it. |
-8 | Decryption failed. Please contact the Tencent Cloud team to deal with it. |
-9 | JSON fields in the TELicense field are incorrect. Please contact the Tencent Cloud team to deal with it. |
-10 | The TE authorization information parsed from the network is empty. Please contact the Tencent Cloud team to deal with it. |
-11 | Failed to write TE authorization information to a local file, possibly due to I/O failure. |
-12 | Download failed, and parsing local assets also failed. |
-13 | Authentication failed. Please check if the .so file is in the package or if the .so path is set correctly. |
3004/3005 | Invalid authorization. Please contact the Tencent Cloud team to deal with it. |
3015 | Bundle ID/Package Name mismatch. Check if the Bundle ID/Package Name used by your app is consistent with the applied one, and ensure you are using the correct license file. |
3018 | The license file has expired. You need to apply for a renewal from Tencent Cloud. |
Others | Please contact the Tencent Cloud team to deal with it. |
assets
directory of the SDK's AAR package.assets
directory of the demo project, named lut
and MotionRes
respectively.TEMenuActivity.java
in the demo project.String resPath = new File(getFilesDir(), AppConfig.getInstance().getBeautyFileDirName()).getAbsolutePath();if (!resPath.endsWith(File.separator)) {resPath = resPath + File.separator;}AppConfig.resPathForSDK = resPath;AppConfig.lutFilterPath = resPath + "light_material/lut";AppConfig.motionResPath = resPath + "MotionRes";new Thread(() -> {Context context = getApplicationContext();int addResult = XmagicApi.addAiModeFilesFromAssets(context, AppConfig.resPathForSDK);Log.d(TAG, "copyRes, add ai model files result = " + addResult);String lutDirNameInAsset = "lut";boolean result = FileUtil.copyAssets(context, lutDirNameInAsset, AppConfig.lutFilterPath);Log.d(TAG, "copyRes, copy lut, result = " + result);String motionResDirNameInAsset = "MotionRes";boolean result2 = FileUtil.copyAssets(context, motionResDirNameInAsset, AppConfig.motionResPath);Log.d(TAG, "copyRes, copy motion res, result = " + result2);}).start();
@Overridepublic int onCustomProcessTexture(int textureId, int textureWidth, int textureHeight) {// The beauty effect SDK processes the textureId here, adds beauty effects and special effects for it, and returns the processed new textureID.}
TECameraBaseActivity.java
in the demo project and use the GLCameraXView
component to add it to your Activity's layout for quick camera preview:<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" />
onCreate()
method://AppConfig.resPathForSDK is the resource path determined during the resource copy stage.mXmagicApi = new XmagicApi(this, AppConfig.resPathForSDK);
Parameter | Meaning |
Context context | Context |
String resDir | |
OnXmagicPropertyErrorListener errorListener | Optional. Callback function implementation class, for handling some error codes during the SDK initialization and usage process. For the meanings of error codes, refer to
API Documentation |
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();}});
@Override public int onCustomProcessTexture(int textureId, int textureWidth, int textureHeight) { return mXmagicApi.process(textureId, textureWidth, textureHeight); }
setEffect
method for version 3.5.0 and later. For detailed information, see the API Documentation.updateProperty
method for version 3.3.0 and earlier. For detailed information, see the API Documentation.//Use this method for version 3.5.0 and later.mXmagicApi.setEffect(String effectName, int effectValue, String resourcePath, Map<String, String> extraInfo)// For example, set the whitening property with intensity//mXmagicApi.setEffect(XmagicConstant.EffectName.BEAUTY_WHITEN, 50, null,null);// Available input parameter properties can be obtained from XmagicResParser.parseRes().// Use this method for version 3.3.0 and earlier.@DeprecatedmXmagicApi.updateProperty(XmagicProperty<?> p);
onResume
: It is recommended to call it in the Activity
's onResume()
method. When called, it will resume the sound in the effects.mXmagicApi.onResume();
onPause
: It is recommended to call it in the Activity's onPause()
method. When called, it will pause the sound in the effects.mXmagicApi.onPause();
@Override public void onGLContextDestroy() { mXmagicApi.onDestroy(); }
no xxx method
exception.-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 virtual human voice-driven model: If this feature is not used, the model is not needed. |
| benchmark | | Used for model adaptation. |
| Light3DPlugin | | Used for 3D stickers. |
| LightBodyPlugin | LightBody3DModel.bundle | Used for 3D human skeleton points. |
| | LightBodyModel.bundle | Used for the body beauty feature. |
| LightCore | | SDK core model resources |
| LightHandPlugin | | Required for gesture stickers and hand-point capabilities. |
| LightSegmentPlugin | | Required for 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-driven library: If this feature is not used, the library is not needed. |
| libc++_shared.so | | libc_shared.so is a shared library of the C standard library. It provides a set of C standard library functions and classes to support the development and operation of C programs. It is widely used in the Android system and is an essential part of C applications and libraries. If your project already includes a C shared library, you can keep only one copy. |
| liblight-sdk.so | | Light SDK core library |
| libpag.so | | Animation file library that the light SDK depends on |
| libtecodec.so | | Codec library that the light SDK depends on |
| libv8jni.so | | JavaScript parsing library that the light SDK depends on |
| libYTCommonXMagic.so | | Used for license authentication |
libs | xmagic-xxxx.aar | | Beauty effect SDK .aar file |
MotionRes | 2dMotionRes | | 2D stickers |
| 3dMotionRes | | 3D stickers |
| avatarRes | | Avatar materials |
| ganMotionRes | | Fun stickers |
| handMotionRes | | Gesture stickers |
| makeupRes | | Makeup stickers |
| segmentMotionRes | | Background segmentation stickers |
unity | aar | | Bridging AAR required for the unity project |
| module | | Original project for the bridging AAR |
Was this page helpful?