HOME
  • GM-3568JHF
  • M4-R1
  • M5-R1
  • SC-3568HA
  • M-K1HSE
  • CF-NRS1
  • CF-CRA2
  • 1684XB-32T
  • 1684X-416T
  • C-3568BQ
  • C-3588LQ
  • GC-3568JBAF
  • C-K1BA
Shop
  • English
  • 简体中文
HOME
  • GM-3568JHF
  • M4-R1
  • M5-R1
  • SC-3568HA
  • M-K1HSE
  • CF-NRS1
  • CF-CRA2
  • 1684XB-32T
  • 1684X-416T
  • C-3568BQ
  • C-3588LQ
  • GC-3568JBAF
  • C-K1BA
Shop
  • English
  • 简体中文
  • SC-3568HA

    • Introduction

      • SC-3568HA Overview
    • Quick Start Guide

      • OpenHarmony Overview
      • Image Flashing
      • Setting Up the Development Environment
      • Hello World Application and Deployment
    • Application Development

      • ArkUI

        • Chapter 1 Introduction to ArkTS Language
        • Chapter 2 Introduction to UI Components and Practical Applications (Part 1)
        • Chapter 3 Introduction to UI Components and Practical Applications (Part 2)
        • Chapter 4 Introduction to UI Components and Practical Applications (Part 3)
      • Expand

        • Chapter 1 Getting Started Guide
        • Chapter 2 Referencing and Using Third-Party Libraries
        • Chapter 3: Application Compilation and Deployment
        • Chapter 4: Command-Line Factory Reset
        • Chapter 5: System Debugging -- HDC (Huawei Device Connector) Debugging
        • Chapter 6 APP Stability Testing
        • Chapter 7 Application Testing
    • Device Development

      • Chapter 1 Environment Setup
      • Chapter 2 Download Source Code
      • Chapter 3 Compiling Source Code
    • Peripheral And Iinterface

      • Raspberry Pi interface
      • GPIO Interface
      • I2C Interface
      • SPI communication
      • PWM (Pulse Width Modulation) control
      • Serial port communication
      • TF Card
      • Display Screen
      • Touch
      • Audio
      • RTC
      • Ethernet
      • M.2
      • MINI-PCIE
      • Camera
      • WIFI&BT
      • Raspberry Pi expansion board
    • Frequently Asked Questions

      • Resource Downloads
  • M-K1HSE

    • Introduction

      • M-K1HSE Introduction
    • Quick Start

      • Development environment construction
      • Source code acquisition
      • Compilation Notes
      • Burning Guide
    • Peripherals and interfaces

      • 01 Audio
      • 02 RS485
      • 03 Display
    • System customization development

      • System transplant
      • System customization
      • Driver Development
      • System Debugging
      • OTA Update

Chapter 3: Application Compilation and Deployment

1. Building and Deploying Your First ArkTS Application (Stage Model)

  1. If you are opening DevEco Studio for the first time, click Create Project to start a new project. Alternatively, if a project is already open, navigate to the menu bar and select File > New > Create Project to initiate a new project setup.
TOOL

2)Select Application Development (this guide uses Application Development as an example; Atomic Service corresponds to Atomic Service development), choose the [OpenHarmony] Empty Ability template, and click Next to proceed to the next configuration step.

TOOL

3)Navigate to the Project Configuration screen, adjust the project storage location as needed, leave other parameters as default, and click [Finish]. The Node section here is used to configure the Node.js version for the current project, allowing selection between existing Node.js installations or downloading a new version.

TOOL

4)The Project Initialization Interface appears as shown below:

TOOL

5)Wait here for a moment until the red running indicator disappears. The final state will be displayed once the process completes.

TOOL

2. Building the First Page

1)Using Text Components

After project synchronization is complete, navigate to the Project window, expand entry > src > main > ets > pages, and open the Index.ets file. You will see that the page structure is composed of Text components. A sample snippet of the Index.ets file is shown below:

// Index.ets
@Entry
@Component
struct Index {
  @State message: string = 'Hello World';

  build() {
    Row() {
      Column() {
        Text(this.message)
          .fontSize(50)
          .fontWeight(FontWeight.Bold)
      }
      .width('100%')
    }
    .height('100%')
  }
}

2)Adding a Button

Building upon the default page, we add a Button component to handle user clicks, enabling navigation to another page. A sample snippet of the 'Index.ets' file is shown below:

// Index.ets
@Entry
@Component
struct Index {
  @State message: string = 'Hello World';

  build() {
    Row() {
      Column() {
        Text(this.message)
          .fontSize(50)
          .fontWeight(FontWeight.Bold)
        // 添加按钮,以响应用户点击
        Button() {
          Text('Next')
            .fontSize(30)
            .fontWeight(FontWeight.Bold)
        }
        .type(ButtonType.Capsule)
        .margin({
          top: 20
        })
        .backgroundColor('#0D9FFB')
        .width('40%')
        .height('5%')
      }
      .width('100%')
    }
    .height('100%')
  }
}

3)HarmonyOS applications can be run using either a Remote Simulator or a Physical Device. The key distinction lies in the fact that running applications via the Remote Simulator does not require application signing. The following section will demonstrate the operation method using a Physical Device as an example:

① Connect the physical device A running HarmonyOS to the computer using a dual-headed USB cable connected to the OTG port. After the system boots up, verify in OsTools → Development Entry that both USB OTG Mode and HDC Debugging Mode are enabled:

TOOL

② The tool interface will display the serial number of the connected device 3568A, as shown below:

TOOL

③ System Signing: Navigate to File > Project Structure… > Project > SigningConfigs, then check the options 'Support HarmonyOS' and 'Automatically generate signature'. Click the prompted 'Sign In' button and log in using your Huawei account. After automatic signing completes, click 'OK'. The configuration interface is shown below:

TOOLTOOLTOOLTOOL

④ In the toolbar at the top right corner of the editor window, click the button to execute the application. The operation result is shown in the figure below:

TOOL

⑤ After the execution completes, the tool interface will appear as follows:

TOOL

The interface display on the physical device is as shown below:

TOOL

Note:

Congratulations! You have successfully developed your first HarmonyOS application using the ArkTS language (Stage model). Now, explore more capabilities of HarmonyOS!


Edit this page on GitHub
Last Updated:
Contributors: zsl, zwhuang
Prev
Chapter 2 Referencing and Using Third-Party Libraries
Next
Chapter 4: Command-Line Factory Reset