1 -> How it works
DevEco Studio allows developers to develop and deploy cloud-side service resources locally, and can call your cloud-side code in device-side projects to truly realize device-cloud integrated development.
Select an appropriate cloud development template and create a device-cloud integrated development project based on the project wizard.
Conduct code development and debugging for cloud-side projects and device-side projects respectively.
illustrate
The code of the cloud-side and device-side projects can be developed in parallel and generally in no order. However, if you need to call the cloud-side code in the device-side code, the cloud-side code must be deployed to the AGC cloud first, so we recommend that you first complete the development, debugging, and deployment of the cloud-side code, and then perform the device-side code development and debugging.
1. Develop cloud-side projects: Develop cloud services provided by Cloud Foundation Kit on the cloud-side projects, including SCFs, cloud objects, and cloud database resources.
To develop an ApsaraDB for the cloud, create an object type in DevEco Studio, add data entries to the object type, and deploy the ApsaraDB for the ApsaraDB to AGC Cloud.
Developing Cloud Objects: Create cloud objects, develop cloud object code, debug cloud objects, and deploy cloud objects to AGC Cloud in DevEco Studio.
Developing SCFs: Create and configure functions, develop function code, debug functions, and deploy functions to AGC Cloud in DevEco Studio.
2. Deploy the cloud-side project: After all the cloud-side project code is developed and debugged, deploy the cloud-side project to AGC Cloud with one click.
Develop the business code of your application under the device-side project. This document describes how to call the cloud-side code that you developed on the device, including calling SCF, calling an object, accessing a cloud database, and calling a cloud storage.
After all the project codes on both sides of the device and cloud are developed, the device and cloud integration project is packaged into an APP and submitted to AGC for application and listing.
2 -> Constraints and Limitations
2.1 -> Supported Devices
Only phones are supported, and running debugging with an emulator is not supported.
2.2 -> Supported Countries
Currently, the service is only available in China (excluding Hong Kong, Macau, and Taiwan).
2.3 -> Supported Signature Methods
Currently, only manual signatures are supported.
3 -> Summary
3.1 -> Key Features and Tools
HUAWEI CLOUD service integration
Cloud DB: You can configure a cloud database model directly in DevEco Studio to synchronize data between on-premises and cloud data in real time.
// 示例:初始化Cloud DB
CloudDBZoneConfig config = new CloudDBZoneConfig("MyDBZone");
AGConnectCloudDB.initialize(context).createCloudDBZone(config);
Cloud Function: Quickly deploys backend logic through @cloudfunction annotations and supports event-driven.
Auth Service: Integrates HUAWEI ID, mobile phone number, and third-party login to configure the user system with one click.
Collaborative development of the front and back-end
API Mock: Locally simulates cloud interface responses and supports parallel development of front-end and back-end operations.
Distributed debugging: View logs and network requests on devices and the cloud in real time.
Data security and synchronization
Device cloud data encryption: HTTPS transmission is enabled by default and field-level encryption is supported.
Conflict resolution strategy: Resolves multi-terminal data conflicts based on timestamps or custom rules.
3.2 -> Development process
- Environment configuration
Step 1: Install DevEco Studio 3.0+ and log in to your Huawei developer account.
Step 2: Create a project in the AppGallery Connect (AGC) console and enable cloud services.
Step 3: Synchronize the cloud configuration to the on-premises project through agconnect-services.json.
- Definition of cloud resources
To define the cloud database model:
// CloudDB模型示例
{
"objects": [{
"name": "User",
"fields": [
{"name": "userId", "type": "String", "isPrimaryKey": true},
{"name": "name", "type": "String"}
]
}]
}
Configure SCF triggers: For example, emails will be sent automatically after the user registers.
- On-device development
Data Manipulation:
// 插入数据到Cloud DB
CloudDBZone zone = AGConnectCloudDB.getInstance().openCloudDBZone(config);
User user = new User("001", "Alice");
zone.executeUpsert(user);
Call SCF:
CloudFunction.call("sendNotification", params)
.addOnSuccessListener(result -> { /* 处理成功 */ })
.addOnFailureListener(e -> { /* 处理失败 */ });
- Debugging and Release
Local simulator test: Use the built-in simulator in DevEco Studio to verify device-cloud interaction.
Brick-and-mortar joint commissioning: Output cloud request details through HiLog.
One-click publishing: Synchronize and package device-side applications and cloud resource configurations.
3.3 -> Typical Scenarios and Optimizations
- Scenario case: Real-time collaborative notes
On-device: Users can edit notes on their HarmonyOS tablet and synchronize them to the cloud in real time.
Cloud: Triggers SCF to generate collaboration links and push notifications to other devices.
Data flow: Device → Cloud DB → SCF → Push Service → other devices.
- Performance optimization strategy
Caching mechanism: Local SQLite caches high-frequency query data.
Pagination loading: Use LazyColumn to load data in the cloud.
Bandwidth optimization: Enable data compression (such as Protocol Buffers).
3.4 -> Common Problems and Solutions
- Data synchronization delay
Check the network status and Cloud DB partition configuration.
Scenario: Enable offline-first mode and automatically sync when the network is restored.
- SCF timed out
Optimization: Split complex logic into multiple SCFs and set a timeout threshold (3 seconds by default).
- Insufficient permissions
Configuration: Set fine-grained read and write permissions on the AGC console.
3.5 -> Summary
With DevEco Studio's device-cloud integrated development capabilities, developers can quickly build intelligent applications with distributed characteristics. Its core advantages are:
Efficient collaboration: Manage front-end and back-end code in a unified environment to reduce tool switching.
Secure and reliable: Built-in HUAWEI CLOUD services ensure data security.
Flexible expansion: Custom SCF can be integrated with third-party services.
Top comments (0)