DEV Community

Cover image for Build the first ArkTS application (Stage model)
liu yang
liu yang

Posted on

Build the first ArkTS application (Stage model)

Setting Up an ArkTS Project in DevEco Studio

Creating a New Project

  • If launching DevEco Studio for the first time, click "Create Project" to start a new project. If you already have a project open, navigate to the menu bar and select File > New > Create Project.
  • Choose "Application" development (in this example, we focus on application development; for service development, select "Atomic Service"). Pick the "Empty Ability" template and click "Next" to proceed to configuration.
  • If you are developing a Native - related project, opt for the "Native C++" template. For details on other templates, refer to the project template introduction.

Image description

Image description

Project Configuration Interface

  • Compatible SDK indicates the minimum compatible API Version. Here, we select 5.0.0 (12) as an example. Keep other parameters at their default settings.

Image description

  • Click "Finish", and the tool will automatically generate sample code and related resources. Wait for the project creation to complete.

ArkTS Project Directory Structure (Stage Model)

  • AppScope > app.json5: Contains global configuration information for the application. For details, refer to the app.json5 configuration file.
  • entry: The HarmonyOS project module, which compiles and builds into an HAP package.
  • src > main > ets: Stores ArkTS source code.
  • src > main > ets > entryability: The entry point for the application/service.
  • src > main > ets > entrybackupability: Provides extended backup and recovery capabilities for the application.
  • src > main > ets > pages: Contains the pages of the application/service.
  • src > main > resources: Holds resource files used by the application/service, such as graphics, multimedia, strings, layout files, etc. For details on resource files, refer to resource classification and access.
  • src > main > module.json5: The module configuration file, which includes configuration information for the HAP package, device - specific application/service configurations, and global application/service configurations. For specifics, refer to the module.json5 configuration file.
  • build-profile.json5: Contains module - level and compilation - related configuration items, including buildOption and targets settings.
  • hvigorfile.ts: The module - level compilation and build task script.
  • obfuscation-rules.txt: The obfuscation rules file. When obfuscation is enabled, during Release - mode compilation, it will obfuscate, compress, and protect the code. For details, refer to enabling code obfuscation.
  • oh-package.json5: Describes the package name, version, entry file (type declaration file), and dependencies, among other information.
  • oh_modules: Stores third - party library dependency information.
  • build-profile.json5: Contains project - level configuration information, including signingConfigs for signing and product configurations. The products can specify the current runtime environment, which defaults to HarmonyOS.
  • hvigorfile.ts: The project - level compilation and build task script.
  • oh-package.json5: Mainly describes global configurations, such as dependency overrides, overrideDependencyMap for dependency rewriting, and parameterFile for parameterized configurations.

Top comments (0)