To downsize the package, you can download the assets
resources, so
libraries, and animated effect resources MotionRes
(unavailable in some basic SDKs) required by the SDK online. After successful download, set the paths of the above files in the SDK.
We recommend you reuse the download logic of the demo. You can also use your existing download service.
If you reuse the demo download logic, note that the checkpoint restart feature is enabled by default in the demo, so that a download can be resumed later if it is interrupted. To use this feature, make sure that your download server supports the checkpoint restart capabilities.
Check method
Check whether the web server supports range requests. If range requests are supported, then the server supports checkpoint restart. Run the following `curl` command on the command line:
curl -i --range 0-9 https://your server address/name of the file to be download
For example:
curl -i --range 0-9 https://mediacloud-76607.gzc.vod.tencent-cloud.com/TencentEffect/Android/2.4.1.119/xmagic_S1-04_android_2.4.1.119.zip
If the returned content contains the `Content-Range` field, the server supports checkpoint restart.
.so
library packages are in jniLibs/arm64-v8a
and jniLibs/armeabi-v7a
.
MD5 file path/filename
in Terminal or use an applicable tool.ResDownloadConfig
in the demo project:ResDownloadUtil.checkOrDownloadFiles
to start download.Note:
- When the SDK version is updated, the corresponding
.so
libraries may also change, and you need to download the.so
libraries again. We recommend you refer to the method in the demo and use the MD5 value for verification.- Regardless of whether you choose to download
.so
libraries on your own or reuse the download service in the demo, check whether they have been downloaded before calling theauth
API of the SDK.ResDownloadUtil
provides the following method for checking. If they have been downloaded, set their paths in the SDK as shown below:
String validLibsDirectory = ResDownloadUtil.getValidLibsDirectory(LaunchActivity.this,
isCpuV8a() ? ResDownloadConfig.DOWNLOAD_MD5_LIBS_V8A : ResDownloadConfig.DOWNLOAD_MD5_LIBS_V7A);
if (validLibsDirectory == null) {
Toast.makeText(LaunchActivity.this,"Libraries are not downloaded. Download them first",Toast.LENGTH_LONG).show();
return;
}
XmagicApi.setLibPathAndLoad(validLibsDirectory);
auth();
assets
ResourcesYou can dynamically download assets
resources as follows:
assets
in your local project:assets
directory need to be retained.brand_name.json
, device_config.json
, phone_info.json
, and score_phone.json
.download_assets.zip
package in the SDK.ResDownloadUtil.checkOrDownloadFiles
to start download and call ResDownloadUtil.getValidAssetsDirectory
to get the path of the downloaded assets
. For detailed directions, see LaunchActivity.java
.Note:
- When the SDK version is updated, the corresponding
assets
may also change, and you need to download theassets
again to ensure compatibility. We recommend you refer to the method in the demo and use the MD5 value for verification.- Regardless of whether you choose to download the
assets
on your own or reuse the download service in the demo, check whetherassets
have been downloaded before capturing video.ResDownloadUtil
provides the following method for checking. If they have been downloaded, set their paths in the SDK. For detailed directions, seeLaunchActivity.java
.
String validAssetsDirectory = ResDownloadUtil.getValidAssetsDirectory(LaunchActivity.this,ResDownloadConfig.DOWNLOAD_MD5_ASSETS);
if (validAssetsDirectory == null) {
Toast.makeText(LaunchActivity.this,"The `assets` are not downloaded. Download them first",Toast.LENGTH_LONG).show();
return;
}
XmagicResParser.setResPath(validAssetsDirectory);
startActivity(intent);
MotionRes
Some basic editions don't have animated effect resources. You can skip this section based on your actual conditions.
Animated effects are divided into six types, and each type has several ZIP packages, each of which contains an animated effect. The file content varies by your purchased edition.
Animated effect resources can be downloaded as needed. For example, download can start after a user enters the relevant feature page or after clicking the icon of an animated effect.
You need to upload these ZIP packages to the server and get the download address of each ZIP package.
Note:The
MotionRes
directory of downloaded animated effect resources must be at the same level aslight_assets
andlight_material
described in the previous section. In addition, each animated effect needs to be extracted and cannot be placed in the same ZIP package.
To download MotionRes
, refer to the ResDownloadUtil.checkOrDownloadMotions
method. We recommend you download such resources one by one.
To reuse the download service in the demo, replace the value of the MOTION_RES_DOWNLOAD_PREFIX
constant in ResDownloadConfig
with your download URL prefix.
Was this page helpful?