Version: 1.8
语言 : 中文
Getting started with OpenHarmony
OpenHarmony player settings

OpenHarmony Start Program

本页详细介绍了Tuanjie Editor在OpenHarmony平台从安装到项目构建运行的全流程,帮助新手快速入门。

Install OpenHarmony Build Support Module

在正式开发OpenHarmony项目前,请确保已经安装了 Tuanjie Hub ,Tuanjie将平台能力封装各个独立的模块中,使用功能前需要添加对应平台构建支持模块。模块可以与Tuanjie Editor一并安装,也可以在安装Tuanjie Editor后,在Tuanjie Hub的Installs目录下的设置选项中进行添加。

Preferences window showing installs for OpenHarmony
Preferences window showing installs for OpenHarmony

Before you get started, check Tuanjie’s Requirements and compatibility documentation for OpenHarmony to make sure you’re aware of any limitations for developing a Tuanjie application for OpenHarmony.

The four modules to install are: - The OpenHarmony Build Support module. - The OpenHarmony Software Development Kit (SDK). - A Java Development Kit. By default, Tuanjie uses OpenJDK. - Node.js SDK Tools

Tuanjie installs OpenHarmony SDK & Node.js SDK and OpenJDK respectively in the SDK, nodejs, and OpenJDK folders under /Tuanjie/Hub/Editor/[EditorVersion]/Editor/Data/PlaybackEngines/OpenHarmonyPlayer/.

Create OpenHarmony Project

顺利安装Tuanjie Editor和Platform Build Support Module后,在Tuanjie Hub的Projects页面点击New project按钮进入项目创建界面,选取需要的工程模板,填写工程名称和路径后创建工程。Tuanjie Editor在OpenHarmopny平台支持Build-in Render PipelineA series of operations that take the contents of a Scene, and displays them on a screen. Unity lets you choose from pre-built render pipelines, or write your own. More info
See in Glossary
Universal Render Pipeline两种渲染管线,相关支持可见Requirements and compatibility documentation请注意,OpenHarmony项目路径只能包含字母、数字、句点、下划线和连字符(-),不能包含空格且不能以句点结尾,否则会导致项目打包失败!

Build OpenHarmony Project

在Tuanjie Editor可以找到Player Settings (Edit > Project Settings > Player)Build Settings (File > BuildSettings) 界面,包含了项目主要的构建配置参数,详情可见对应文档。 在项目开发前需要在Build Settings 界面将项目切换到OpenHarmony平台。

项目开发完毕后,通过设置Export Project选项,可以选取两种构建项目的方式。

  • 直接导出hap包
    • 取消勾选Export Project选项,点击Build And Run构建项目,在导出hap包时,若同时连接了设备会将hap包安装到设备上运行,选用Build选项构建项目则需要手动安装hap包。
    • OpenHarmony需要为hap包添加应用签名,才能安装hap包到设备,签名步骤详情请见OpenHarmony keystores
  • 导出工程项目
    • 勾选Export Project选项,点击Export导出工程项目,1.7.1以前的版本可以在Export Project Type选择DefaultUse As A Library两种模式,1.7.1版本后只支持Use As A Library模式导出工程项目。
    • 导出工程项目后,可通过 DevEco Studio IDE工具进行二次开发,DevEco Studio IDE的安装与使用详情请见OpenHarmony run program in DevecoStudio。Export Project模式下应用签名可以通过OpenHarmony keystores 配置,也可以通过DevEco Studio IDE的签名系统自动生成。
    • 对项目的调试需要在Export ProjectDevelopment Build模式下进行,详情请见Testing and debugging

Customizing dependencies

You should use the Tuanjie Hub to install OpenHarmony SDK & Node.js tools and OpenJDK to ensure that you receive the correct versions and configurations. However, there are situations where it’s useful to change the SDK, Node.js, or JDK that Tuanjie uses to build applications for OpenHarmony. For example, if you have multiple versions of Tuanjie with the same dependencies and you don’t want to duplicate the installation of the SDK, Node.js, and JDK, you can specify a shared location.

To make Tuanjie use a custom version of a dependency:

  1. Download the custom version of the dependency. Warning: Tuanjie only officially supports versions of the OpenJDK, SDK and Node.js that it supplies through the Hub.
  2. In Tuanjie, select Edit > Preferences (macOS: Tuanjie > Preferences).
  3. In the left navigation column, select External Tools. The OpenHarmony section of the External Tools panel contains entries for SDK, Node.js, and JDK. Each entry contains:
    • A checkbox that indicates whether to use the version that Tuanjie provides or a custom version.
    • The path to the dependency’s installation folder.
      Preferences window showing external tools settings for OpenHarmony
  4. To customize the installation for any of these dependencies, disable the dependency’s respective …installed with Tuanjie (recommended) checkbox then click Browse and select the installation folder for the custom dependency.
Getting started with OpenHarmony
OpenHarmony player settings