DEV Community

ZHZL-m
ZHZL-m

Posted on

【Journey of HarmonyOS Next】DevEco Studio User Guide (2)

Image description

1 -> Introduction to project templates

DevEco Studio supports the development of multiple types of applications/metaservices, presets a wealth of project templates, and can easily create projects suitable for various devices according to the project wizard, and automatically generate corresponding code and resource templates. At the same time, DevEco Studio also provides a variety of programming languages for developers to develop applications/metaservices, including ArkTS, JS, and C/C++.

Image description

The following table describes the development languages and templates supported by project templates.

Image description

2 -> Create a new project

When you start developing an application/metaservice, you first need to create a new project according to the project creation wizard, and the tool will automatically generate the corresponding code and resource templates.

illustrate

When running a DevEco Studio project, it is recommended that you have at least 2 GB of free memory space per running window.

2.1 -> Create and configure a new project

DevEco Studio provides basic project template resources, and different templates may support different device types and API versions.

2.1.1 -> Create a HarmonyOS project

  1. Use the following methods to open the Project Creation Wizard page:

If you do not currently have any projects open, you can select Create Project on the welcome page of DevEco Studio to start creating a new project.
If you already have a project open, you can create a new project by selecting File > New > Create Project in the menu bar.

  1. According to the Project Creation Wizard, select Create Application or Atomic Service. Then select the required Ability project template and click Next.

illustrate

Since API version 11, Atomic Service meta-service engineering development has been supported.

Atomic Service meta-service projects do not support Native development.

Image description

  1. On the project configuration page, you need to configure the basic information of the project according to the wizard.

Project name: The name of the project, which can be customized, consists of uppercase and lowercase letters, numbers, and underscores.
Bundle name: Identifies the package name of the app, which is used to identify the uniqueness of the app.
illustrate

App package name requirements:

It must be a string separated by a period (.) and contain at least three paragraphs, and only letters, numbers, and underscores (_) are allowed in each paragraph, such as "com.example.myapplication".
The first paragraph begins with an English letter, the unfirst paragraph begins with a number or a letter, and each paragraph ends with a number or letter, such as "com.01example.myapplication".
Multiple dots (..) are not allowed to appear consecutively, such as "com.example.. myapplication ”。
The length is 7~128 characters.
Save location: The local storage path of the project file, consisting of uppercase and lowercase letters, digits, and underscores, and cannot contain Chinese characters.
Compatible SDK: the minimum API version that is compatible with the SDK.
Module name: The name of the module.
Device type: the device type supported by the project template.

Image description

  1. Click Finish, the tool will automatically generate sample code and related resources, and wait for the project to be created.

2.2.2 -> Create an OpenHarmony project

  1. After creating a HarmonyOS project, modify the relevant fields in the project-level build-profile.json5 file as follows:

Add the compileSdkVersion field to the build-profile.json5 file at the project level.

Assign the compatibleSdkVersion and compileSdkVersion fields to integer types.

Change the runtimeOS from HarmonyOS to OpenHarmony.

"products": [
  {
    "name": "default",
    "signingConfig": "default", 
    "compileSdkVersion": 11,    //指定OpenHarmony应用编译时的版本,当前以API 11为例
    "compatibleSdkVersion": 11, //指定OpenHarmony应用兼容的最低版本,当前以API 11为例
    "runtimeOS": "OpenHarmony",
  }
],
Enter fullscreen mode Exit fullscreen mode
  1. Click Sync Now to sync. Click Yes in the Sync Check pop-up window, agree to switch the phone in the module.json5/config.json file to the default type supported by OpenHarmony, and delete other device types that are not applicable to OpenHarmony.

illustrate

If you select a native C++ template to create an OpenHarmony application that needs to run on an RK development board, add the abiFilters field to the buildOption/externalNativeOptions field in the build-profile.json5 file of the Native module and assign the value to armeabi-v7a.

Top comments (0)