2. Find the src/main/assets folder in app (if there isn't this folder, create one). Check if there is a MotionRes folder. Copy it to ../src/main/assets.
3. Open AndroidManifest.xml in app and add the following tag to application.
<uses-native-library
android:name="libOpenCL.so"
android:required="true" />
// `true` here indicates that the application would not run properly without the library. The system does not allow installing the application on a device without the library.
//`false` indicates that the application can use the library if it is available, but can also run without it. It can be installed on a system without the library. If you set the parameter to `false`, you need to deal with the issues that may arise due to the absence of the library.
// Description at the Android website: %!s(<nil>)
It will look like this:
4. Obfuscation configuration.
If you enable optimization (by setting minifyEnabled to true) when building your application, some code that is not called at the Java layer will be removed. However, such code may be called at the native layer, causing a no xxx method error.
To fix the issue, add the following keep rules to prevent the code from being removed:
-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.**{*;}
1. Add effect resources to your project (your resources may differ from those in the screenshot):
2. Copy the four classes in demo/lib/producer – BeautyDataManager, BeautyPropertyProducer, BeautyPropertyProducerAndroid, and BeautyPropertyProducerIOS – to your Flutter project. They are used to configure effect resources and display effect options in the effect panel.
Step 2. Reference the Flutter SDK
Reference from GitHub: Add the following reference in the pubspec.yaml file of your project:
Reference locally: Download the latest edition of the Beauty AR Flutter SDK. Copy the androidios, and lib folders and the pubspec.yaml and tencent_effect_flutter.iml files to your project directory, and add the following code in the pubspec.yaml file of your project.
tencent_effect_flutter:
path: ../
tencent_effect_flutter only serves as a bridge. It is Xmagic that implements effects. The latest edition of Xmagic is used by default.
You can use the following methods to update your SDK:
Android
iOS
Execute flutter pub upgrade in your project directory or click Pub upgrade in the top right of the subspec.yaml page.
Execute flutter pub upgrade in your project directory and then run pod update in the ios directory.
Step 3. Bind TRTC and Beauty
Android
iOS
Add the following code to oncreate of the application class (or onCreate of FlutterActivity):
void_initSettings(InitXmagicCallBack callBack) async {_setResourcePath();/// Copying the resource only needs to be done once. Once it has been successfully copied in the current version, there is no need to copy it again in future versions.if(await isCopiedRes()){
callBack.call(true);return;}else{_copyRes(callBack);}}void_setResourcePath() async {String resourceDir = await ResPathManager.getResManager().getResPath();TXLog.printlog(
'$TAG method is _initResource ,xmagic resource dir is $resourceDir');TencentEffectApi.getApi()?.setResourcePath(resourceDir);}void_copyRes(InitXmagicCallBack callBack){_showDialog(context);TencentEffectApi.getApi()?.initXmagic((result){if(result){saveResCopied();}_dismissDialog(context);
callBack.call(result);if(!result){Fluttertoast.showToast(msg:"initialization failed");}});}
V0.3.1.1 and earlier:
String dir = await BeautyDataManager.getInstance().getResDir();
You can customize effect panel data in the BeautyDataManager, BeautyPropertyProducer, BeautyPropertyProducerAndroid, and BeautyPropertyProducerIOS classes.
Delete effect resources:
Your license may not support some beautification or body retouch effects, which you can delete from the panel.
For example, to delete lipstick effects, delete the code below from getBeautyData of BeautyPropertyProducerAndroid and BeautyPropertyProducerIOS.