ML Kit provides two SDK integration modes: full SDK and base SDK. You can select either one based on your needs. For details, please refer to Full SDK and base SDK in Overview.
Integrate the base SDK package and then the model package. The following table describes the model package.
Package Type | Package Name | SDK Size | Storage Position |
Model package + Algorithm package | ml-computer-vision-image-classification-model | 6.1M | com.huawei.hms:ml-computer-vision-image-classification-model:1.0.4.300 |
The following is the sample code for integration in full SDK mode:
- dependencies{
- // Import the base SDK.
- implementation 'com.huawei.hms:ml-computer-vision-classification:1.0.4.300'
- // Import the image classification model package.
- implementation 'com.huawei.hms:ml-computer-vision-image-classification-model:1.0.4.300'
- }
The sample code is as follows:
- dependencies{
- implementation 'com.huawei.hms:ml-computer-vision-classification:1.0.4.300'
- }
After integrating the SDK in either mode, add the following configuration to the file header:
- apply plugin: 'com.huawei.agconnect'
Add the configuration following the configuration item below:
- apply plugin: 'com.android.application'
To enable your app to automatically update the latest machine learning model on a device after the user installs your app downloaded from HUAWEI AppGallery, add the following statements to the AndroidManifest.xml file of your app:
- <manifest
- ...
- <meta-data
- android:name="com.huawei.hms.ml.DEPENDENCY"
- android:value= "label"/>
- ...
- </manifest>