目录

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)

In this mode, you need to integrate the base SDK and then the algorithm package required by your app. The following table describes the algorithm package.

Package TypePackage NameSDK SizeStorage Position
Language detection algorithm packageml-computer-language-detection-model5.4M

com.huawei.hms:ml-computer-language-detection-model:2.0.0.303

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-language-detection:2.0.0.303'
  4.    // Import the language detection algorithm package.
  5.    implementation 'com.huawei.hms:ml-computer-language-detection-model:2.0.0.303'
  6. }

Mode 2: Base SDK Integration

The sample code is as follows:

  1. dependencies{
  2.    implementation 'com.huawei.hms:ml-computer-language-detection:2.0.0.303'
  3. }

Adding the Configuration to the File Header

After integrating the SDK, 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 Machine Learning Model

Add the following statements to theAndroidManifest.xmlfile. After a user installs your app from HUAWEI AppGallery, the machine learning model is automatically updated to the user's device.

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