1 Building the First ArkTs Application - HelloWorld
1.1 Creating a Project with DevEco Studio
Double-click the DevEco Studio shortcut icon on the desktop.
Then you will enter the interface as shown in the figure below. Create a project and enter the project interface.

- Select Application App Development (this article takes app development as an example. Atomic Service corresponds to atomic service development), select the template "Empty Ability", and click Next for further configuration.

- Enter the project configuration interface, modify the project storage path, project name, and compatible SDK version. Other parameters can keep the default settings. Click Finish to create the project. Note: The board-side API version of M4-R1 development board is API 12, so select 5.0.0(12) for Compatible SDK.

- The project initialization interface is as follows. Wait until the Build status bar outputs the statement within the red box at the bottom, indicating initialization is complete:

1.2 Configuring SDK in DevEco Studio
- Select File -> Settings in the menu bar.

- Enter the Settings window, select OpenHarmony SDK, select the SDK installation location, then check API Version 12, download all related content about API Version 12, and click [Apply] to download.

Because we have already downloaded API Version 12, we use API Version 11 as an example.
Note:
If you have already downloaded API 12 as shown in the interface above, you can skip the SDK configuration step.

- After clicking [Apply], a Confirm Change pop-up window will appear. Click [OK].

- Wait for the SDK download to complete.

- When [Finish] becomes bright, the download is complete. Click [Finish].

1.3 Flashing the Program to the Board
1.3.1 Default Program Function Introduction
After the project synchronization is complete, in the "Project" window, click "entry > src > main > ets > pages", open the "Index.ets" file. You can see that the default program page of the app project consists of Text components.
The function implemented by this application is: Click the Hello World text component to switch to Welcome.
The example of "Index.ets" file is as follows:
@Entry
@Component
struct Index {
@State message: string = 'Hello World';
build() {
RelativeContainer() {
Text(this.message)
.id('HelloWorld')
.fontSize($r('app.float.page_text_font_size'))
.fontWeight(FontWeight.Bold)
.alignRules({
center: { anchor: '__container__', align: VerticalAlign.Center },
middle: { anchor: '__container__', align: HorizontalAlign.Center }
})
.onClick(() => {
this.message = 'Welcome';
})
}
.height('100%')
.width('100%')
}
}1.3.2 Signing File Configuration
- Connect the real device M4-R1 equipped with the OpenHarmony system to the computer via USB to Type-C cable and OTG port (the device is in debugging mode by default). The tool interface will display the serial number of the connected device M4-R1, as shown in the following figure:

- Open the project-level build-profile.json5 and modify the products to the following code:
"products": [
{
"name": "default",
"signingConfig": "default",
"compileSdkVersion": 12,
"compatibleSdkVersion": 12,
"targetSdkVersion": 12,
"runtimeOS": "OpenHarmony",
"buildOption": {
"strictMode": {
"caseSensitiveCheck": true,
"useNormalizedOHMUrl": true
}
}
}
]After modification, a blue prompt bar appears at the bottom. Click "Sync Now" in the prompt bar to synchronize the project.

If a Sync Check pop-up prompt appears as shown in the following figure, click Yes.

When Sync Now is complete, the Build status bar at the bottom displays the information as shown in the following figure.

Select File > Project Structure in the menu bar, and select Signing Configs in the pop-up window for signing.

As shown in the figure, because the M4-R1 development board is an OpenHarmony system, check "Automatically generate signature", do not check "Support HarmonyOS", and proceed with automatic signing.

After the signing information appears as shown in the following figure, click OK. The signing content signingConfigs will be written into the project-level build-profile.json5.


Wait for synchronization to complete.

1.3.3 Running the Application
Return to the DevEco Studio project engineering interface and click Run 'entry' in the toolbar to run the application on the development board.

The M-K1HSE real device effect is as shown in the figure:

After clicking the Hello World text, the switching effect is as shown in the figure:

