.aar
文件到 app 工程 libs
目录下。../src/main/assets
目录下,如果 SDK 包中的 MotionRes 文件夹内有资源,将此文件夹也拷贝到 ../src/main/assets
目录下 。../src/main/jniLibs
目录下。build.gradle
添加依赖引用:android{...defaultConfig {applicationId "修改成与授权lic绑定的包名"....}packagingOptions {pickFirst '**/libc++_shared.so'}}dependencies{...compile fileTree(dir: 'libs', include: ['*.jar','*.aar'])//添加 *.aar}
dependencies{implementation 'com.google.code.gson:gson:2.8.2'//2.6.0 版本及之后需要添加implementation 'androidx.exifinterface:exifinterface:1.3.3'//3.5.0 版本及之后需要添加implementation 'com.tencent.tav:libpag:4.3.33-noffavc'}
dependencies {//例如:S1-04套餐如下:implementation 'com.tencent.mediacloud:TencentEffect_S1-04:版本号'//“版本号”可以在官网的“版本历史”页面看到,例如 3.0.0.13。“版本号”也可以使用"latest.release" ,//但请注意:这会让您使用的SDK始终保持最新版,在一些变化比较大的版本上可能不符合您的预期,请慎重使用"latest.release"
defaultConfig {ndk {abiFilters "armeabi-v7a", "arm64-v8a"}}
../assets/MotionRes
../assets/lut
版本 | Maven 地址 |
A1 - 01 | implementation 'com.tencent.mediacloud:TencentEffect_A1-01:版本号' |
A1 - 02 | implementation 'com.tencent.mediacloud:TencentEffect_A1-02:版本号' |
A1 - 03 | implementation 'com.tencent.mediacloud:TencentEffect_A1-03:版本号' |
A1 - 04 | implementation 'com.tencent.mediacloud:TencentEffect_A1-04:版本号' |
A1 - 05 | implementation 'com.tencent.mediacloud:TencentEffect_A1-05:版本号' |
A1 - 06 | implementation 'com.tencent.mediacloud:TencentEffect_A1-06:版本号' |
S1 - 00 | implementation 'com.tencent.mediacloud:TencentEffect_S1-00:版本号' |
S1 - 01 | implementation 'com.tencent.mediacloud:TencentEffect_S1-01:版本号' |
S1 - 02 | implementation 'com.tencent.mediacloud:TencentEffect_S1-02:版本号' |
S1 - 03 | implementation 'com.tencent.mediacloud:TencentEffect_S1-03:版本号' |
S1 - 04 | implementation 'com.tencent.mediacloud:TencentEffect_S1-04:版本号' |
v_cube.license
。//如果仅仅是为了触发下载或更新license,而不关心鉴权结果,则第4个参数传入null。TELicenseCheck.getInstance().setXMagicLicense(context, URL, KEY, null);
.java
),再去做鉴权:// 如果您的so库是从网络下载的,那么请在调用TELicenseCheck.getInstance().setTELicense之前,先设置so的路径,否则鉴权会失败。// XmagicApi.setLibPathAndLoad(validLibsDirectory);// 如果您的so内置在apk包内,则无需调用上面的方法。TELicenseCheck.getInstance().setTELicense(context, URL, KEY, new TELicenseCheckListener() {@Overridepublic void onLicenseCheckFinish(int errorCode, String msg) {//注意:此回调不一定在调用线程if (errorCode == TELicenseCheck.ERROR_OK) {//鉴权成功} else {//鉴权失败}}});
错误码 | 说明 |
0 | 成功。Success |
-1 | 输入参数无效,例如 URL 或 KEY 为空 |
-3 | 下载环节失败,请检查网络设置 |
-4 | 从本地读取的 TE 授权信息为空,可能是 IO 失败引起 |
-5 | 读取 VCUBE TEMP License文件内容为空,可能是 IO 失败引起 |
-6 | v_cube.license 文件 JSON 字段不对。请联系腾讯云团队处理 |
-7 | 签名校验失败。请联系腾讯云团队处理 |
-8 | 解密失败。请联系腾讯云团队处理 |
-9 | TELicense 字段里的 JSON 字段不对。请联系腾讯云团队处理 |
-10 | 从网络解析的 TE 授权信息为空。请联系腾讯云团队处理 |
-11 | 把TE授权信息写到本地文件时失败,可能是 IO 失败引起 |
-12 | 下载失败,解析本地 asset 也失败 |
-13 | 鉴权失败,请检查 so 是否在包里,或者已正确设置 so 路径 |
3004/3005 | 无效授权。请联系腾讯云团队处理 |
3015 | Bundle Id / Package Name 不匹配。检查您的 App 使用的 Bundle Id / Package Name 和申请的是否一致,检查是否使用了正确的授权文件 |
3018 | 授权文件已过期,需要向腾讯云申请续期 |
其他 | 请联系腾讯云团队处理 |
.java
。//将resPath设置给下边copyRes方法的mResPath变量String resPath = new File(getFilesDir(), AppConfig.getInstance().getBeautyFileDirName()).getAbsolutePath();//copy资源文件到私有目录,只需要做一次//需要在子线程调用public 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;}
.java
。mXmagicApi = new XmagicApi(this, 下载的资源文件本地路径,new XmagicApi.OnXmagicPropertyErrorListener());
<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" />
.java
。@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()
方法中。//resPath是步骤二中第一步设置的路径mXmagicApi = new XmagicApi(this, resPath,new XmagicApi.OnXmagicPropertyErrorListener());
参数 | 含义 |
Context context | 上下文 |
String resDir | 资源文件目录,详见请参见 步骤二 |
OnXmagicPropertyErrorListener errorListener | 回调函数实现类 |
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);
//3.5.0版本及之后使用此方法mXmagicApi.setEffect(String effectName, int effectValue, String resourcePath, Map<String, String> extraInfo)// 可用的入参属性可以从 XmagicResParser.parseRes() 获得// 3.3.0版本及之前使用此方法mXmagicApi.updateProperty(XmagicProperty<?> p);
Activity
的 onResume()
方法中调用。//恢复美颜中的声音效果,部分素材包含音频效果mXmagicApi.onResume();
onPause()
方法调用。//暂停素材声音,不分素材包含音频效果mXmagicApi.onPause();
//注意,此方法需要在GL线程中调用mXmagicApi.onDestroy();
no xxx method
的异常。-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.** { *;}
文件类型 | 说明 | ||
assets | audio2exp | | avatar 虚拟人语音驱动模型,如果不使用该功能,则无需该模型 |
| benchmark | | 机型适配使用 |
| Light3DPlugin | | 3D 贴纸使用 |
| LightBodyPlugin | LightBody3DModel.bundle | 人体 3D 骨骼点位使用 |
| | LightBodyModel.bundle | 美体功能使用 |
| LightCore | | SDK 核心模型资源 |
| LightHandPlugin | | 手势贴纸、手部点位能力需要 |
| LightSegmentPlugin | | 背景分割能力需要使用 |
| lut | | 免费的滤镜资源 |
demo_xxx_android_xxxx | | | demo 工程 |
jniLibs | libace_zplan.so | | 3D 引擎库 |
| libaudio2exp.so | | avatar 虚拟人语音驱动库,如果不使用该功能,则无需该库 |
| libc++_shared.so | | libc++_shared.so 是一个 C++ 标准库的共享库,它提供了一组C++ 标准库函数和类,用于支持 C++ 程序的开发和运行。它在 Android 系统中被广泛使用,是 C++ 应用程序和库的重要组成部分。如果您的工程中已有 C++ 共享库,可以只保留一份 |
| liblight-sdk.so | | light sdk 核心库 |
| libpag.so | | light sdk 依赖的动画文件库 |
| libtecodec.so | | light sdk 依赖的编解码库 |
| libv8jni.so | | light sdk 依赖的用于解析 JavaScript 的库 |
| libYTCommonXMagic.so | | license 鉴权使用 |
libs | xmagic-xxxx.aar | | 美颜 SDK 的 aar 文件 |
MotionRes | 2dMotionRes | | 2D 贴纸 |
| 3dMotionRes | | 3D 贴纸 |
| avatarRes | | Avatar素材 |
| ganMotionRes | | 童趣贴纸 |
| handMotionRes | | 手势贴纸 |
| makeupRes | | 美妆贴纸 |
| segmentMotionRes | | 背景分割贴纸 |
unity | aar | | unity 项目需要使用的桥接 aar |
| module | | 桥接 aar 的原工程 |
本页内容是否解决了您的问题?