目录

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.

Mode 1: Full SDK Integration (Recommended)

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:

  1. dependencies{  
  2.    // Import the base SDK.
  3.    implementation 'com.huawei.hms:ml-computer-vision-classification:1.0.4.300'
  4.    // Import the image classification model package.
  5.    implementation 'com.huawei.hms:ml-computer-vision-image-classification-model:1.0.4.300'
  6. }

Mode 2: Base SDK Integration

The sample code is as follows:

  1. dependencies{
  2.    implementation 'com.huawei.hms:ml-computer-vision-classification:1.0.4.300'
  3. }

Adding Configurations to the File Header

After integrating the SDK in either mode, add the following configuration to the file header:

  1. apply plugin: 'com.huawei.agconnect'
Notice:

Add the configuration following the configuration item below:

  1. apply plugin: 'com.android.application'

Automatically Updating the Latest Machine Learning Model

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:

  1. <manifest
  2.    ...
  3.    <meta-data              
  4.        android:name="com.huawei.hms.ml.DEPENDENCY"  
  5.        android:value= "label"/>
  6.    ...
  7. </manifest>