Matter Vertical Category SDK Integration
1. Overview
This document mainly introduces how to integrate the Matter Vertical Category SDK.
2. Prerequisites
- Confirm completion Preparation
- Confirm the completion of Environment Build
3. Features
3.1 Core Functions
- Supports Aqara Matter hub network configuration
- Supports Aqara Matter hub device control
- Supports Matter sub-device network configuration
- Supports Matter sub-device control
PS: Currently, Matter sub-devices cannot be directly configured and connected through the SDK. They must be connected via an Aqara Matter hub (using Aqara's private Magic Pair protocol) before device configuration and control can be performed.
3.2 SDK Size
| Dependency | Description | Size |
|---|---|---|
| React Native (0.63.4) | React Native framework | 10MB |
| Aqara bridge layer | Required components for SDK operation | 24MB |
| Others | Other components required for SDK operation | 14MB |
| Total | - | 48MB |
Note: 48MB represents the maximum incremental size of SDK integration, which occurs when there is no overlap between the third-party app’s dependencies and those of the SDK. In most cases, it will be smaller.
3.3 Compatibility Information
The Matter SDK requires the latest compilation tools and environment. The following are the necessary requirements:
Supported Android Versions
| Parameter | Version | Description |
|---|---|---|
| minSdkVersion | 26 | Android 8 |
| targetSdkVersion | 34 | Android 14 |
| compileSdk | 34 | Android 14 |
Build Tools & Environment
| Parameter | Minimum Version Requirement | Description |
|---|---|---|
| Android Studio Version | 2024.3.1 | Optional |
| Android Gradle Plugin Version | 8.7 | Optional |
| Gradle Version | 8.9 | Required |
| JDK Version | 17 | Required |
| NDK Version | 27.0.12077973 | Optional |
| Kotlin Version | 2.1.0 | Required |
| SDK Build Tools | 34.0.0 | Required |
Note: If these conditions are not met, the demo or SDK may not function properly.
3.3.1 New Project Creation
If you are starting a new project, simply create a new one using the latest version of Android Studio (2024.3.1) that meets the requirements above.
3.3.2 Upgrading an Existing Project
If you are upgrading an existing project, updating Kotlin to version 2.0 may affect your code or business logic. Below are some official reference documents:
Appendix 1: Google Official Docs - Android Studio & AGP Version Compatibility
Appendix 2: Google Official Docs - AGP Upgrade Guide
Appendix 3: Google Official Docs - Kotlin Upgrade Guide
Appendix 4: Gradle Official Docs - Gradle and Kotlin Version Compatibility
4. Integration
4.1 Install Node
Before integrating the Matter SDK, you need to install React Native-related dependencies; otherwise, compilation and packaging will fail. It’s recommended to create a new branch for SDK integration.
| Dependency | Version Requirement |
|---|---|
| Node.js | >=14 |
For more information about React Native, refer to the React Native Official Guide
4.1.1 macOS
We recommend installing Node via Homebrew:
Install Node
brew install node
4.1.2 Windows
We recommend installing Node via Chocolatey:
Install Node
choco install -y nodejs-lts
Note: If Node is already installed, ensure that the version is greater than or equal to 14.
4.2 Configure Node Dependencies for Matter SDK
4.2.1 Create package.json in the Project Root Directory
In the root directory of your Android project, create a package.json file and copy the following content into it:
{
"name": "rn_demo_0614",
"version": "0.0.1",
"private": true,
"scripts": {
"android": "react-native run-android",
"ios": "react-native run-ios",
"start": "react-native start",
"test": "jest",
"lint": "eslint ."
},
"dependencies": {
"@react-native-community/async-storage": "^1.11.0",
"lodash": "^4.17.15",
"prop-types": "^15.7.2",
"react": "17.0.1",
"react-native": "0.63.4",
"react-native-gesture-handler": "^1.5.2",
"react-native-reanimated": "^1.4.0",
"react-native-root-toast": "^3.2.0",
"react-native-screens": "^1.0.0-alpha.23",
"react-navigation": "^4.0.10",
"react-redux": "^7.1.3",
"redux": "^4.0.4",
"redux-logger": "^3.0.6",
"redux-thunk": "^2.3.0",
"reselect": "^4.0.0"
},
"devDependencies": {
"@babel/core": "7.7.4",
"@babel/runtime": "7.7.4",
"@react-native-community/eslint-config": "2.0.0",
"babel-jest": "26.6.3",
"eslint": "7.16.0",
"jest": "26.6.3",
"jetifier": "^1.6.5",
"metro-react-native-babel-preset": "0.64.0",
"react-navigation-stack": "^1.10.3",
"react-test-renderer": "17.0.1"
},
"jest": {
"preset": "react-native"
}
}
4.2.2 Run Command in Project Root Directory to Download Dependencies
Run the following command in the terminal. It will download the dependencies defined in package.json and generate a node_modules folder in the project root.
npm install --legacy-peer-deps
4.3 Integrate Matter SDK
4.3.1 Edit build.gradle or settings.gradle in the Project Root
repositories {
maven {
url "$rootDir/node_modules/react-native/android"
}
}
4.3.2 Edit build.gradle in the app Directory
dependencies {
// Unified initialization, ensure using the latest version
implementation 'com.lumi.external:core:2.1.69'
implementation 'com.lumi.commonui:ui:1.4.105'
// Matter SDK, ensure using the latest version
implementation 'com.lumi.sdk:reactnative:4.5.7'
// Matter Network Configuration SDK, ensure using the latest version
implementation 'com.lumi.module.access:access:3.4.127'
implementation 'com.lumi.module.smart_connect:connect:3.4.127'
// Thread-related
implementation 'com.lumi.api:thread:1.0.21'
}
4.3 Initialization
4.3.1 Unified Initialization
See Environment Construction - Unified Initialization
5. Code Obfuscation
-dontwarn com.facebook.**
-keep class com.facebook.** { *; }