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

Hello World Application and Deployment

1. Hello World Application and Deployment: Building the First ArkTS Application (Stage Model)

a. If this is your first time opening DevEco Studio, click [Create Project] to start a new project. If a project is already open, navigate to the menu bar and select File > New > Create Project to create a new one.

TOOL

b. Select Application Development (this article uses application development as an example, with Atomic Service corresponding to atomic service development), choose the template "[OpenHarmony]Empty Ability", and click [Next] to proceed with configuration.

TOOL

c. Access the project configuration interface, adjust the project storage location as needed, leave other parameters at their default settings, and click [Finish] to complete the setup.

The Node configuration specifies the Node.js version for the current project. You can choose to use an existing Node.js installation or download a new version.

TOOL

d. The project initialization interface is shown below:

TOOL

e. Wait here briefly until the red progress indicator stops. Once the process completes, the final state will be achieved.

TOOL

2. Build the First Page

a. Use a Text Component

After project synchronization completes, navigate to "entry > src > main > ets > pages" in the "Project" window, open the "Index.ets" file, and observe that the page is composed of Text components. An example of the "Index.ets" file content 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%')	  
   }  
   }

b. Add a Button

Based on the default page, we add a Button component that responds to user clicks to navigate to another page. An example of the "Index.ets" file content 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%')
   }
   }

c. HarmonyOS apps can be run using either remote emulators or physical devices. The key difference is that running apps via remote emulators does not require code signing. Below, we will demonstrate the process of running a HarmonyOS app using a physical device as an example:

1.Connect the HarmonyOS-powered physical device SC-3568HA to a computer using a dual-ended USB cable via the OTG port, with the device defaulting to debugging mode.

2.The tool interface will display the serial number of the connected device SC-3568HA as follows:

TOOL

3.System Signing:

Navigate to File > Project Structure… > Project > SigningConfigs.

TOOL

Check the options "Support HarmonyOS" and "Automatically generate signature".
Click "Sign In" as prompted, then log in with your Huawei account.

TOOLTOOL

Wait for the automatic signing process to complete, then click "OK".

TOOL

4.In the toolbar at the top-right corner of the editing window, click the TOOL button to execute the project. The result is displayed as follows:

TOOL

5.After the execution completes, the tool interface will display as follows:

TOOL

The real device interface of SC-3568HA is displayed as follows:

TOOL

Congratulations!

You've successfully built your first HarmonyOS app using ArkTS (Stage model). Now, dive into exploring more HarmonyOS capabilities!


Edit this page on GitHub
Last Updated:
Contributors: zsl, zwhuang
Prev
Setting Up the Development Environment