Getting Started with Hongmeng Development: Quick Repair Command Line Debugging Development Guide

Quick fix command line debugging development guide

At the current stage, HarmonyOS provides developers with command line debugging and development tools for use. For example, the sample application with the package name com.ohos.quickfix has a version number of 1000000. There is a problem that needs to be fixed in the current version of the application. In this case, developers can refer to the following guidance and use the quick repair capability to solve the application problem.

Write the configuration file patch.json

Currently, DevEco Studio does not support the configuration of patch.json, so developers can write the file according to project needs and place it in any directory of the project so that subsequent packaging tools can find the file. Create a new patch.json file locally. The configuration writing example is as follows:

{    "app" : {        "bundleName" : "com.ohos.quickfix",        "versionCode" : 1000000, // 应用版本号        "versionName" : "1.0.0.1",        "patchVersionCode" : 1000000, // 补丁版本号        "patchVersionName" : "1.0.0.1"    },    "module" : {        "name" : "entry",        "type" : "patch",        "deviceTypes" : [            "default",            "tablet"        ],        "originalModuleHash" : "11223344556677889900" // 待修复hap包的sha256值,可采用SHA256生成器自行生成    }}

Generate quick fix file

Code to quickly repair TS files

  • After modifying the TS file in DevEco Studio and compiling HAP, you can find the corresponding abc file in the project directory, such as build\default\cache\default\LegacyCompileETS\jsbundle\temporary\pages\index.abc.

Quickly fix code in C++

  • Compile the original C++ code in DevEco Studio to generate a .so file; repair the original C++ code and compile and generate a new .so file. This so can be found in the project directory, such as build\default\intermediates\libs\default\arm64-v8a\libentry.so.

  • View diff.exe in the toolchains folder of the local HarmonyOS SDK path. Through this tool, a quick repair file of .so is generated based on the new .so file and the old .so file. The command is as follows:

    $ diff.exe -s Example.z.so -d Example.z.so -p Example.z.so.diff
    

    Meaning of command line parameters:

  • -s: path of old so

  • -d: path of new so

  • -p: Path to the generated differential file

Generate .hqf quick fix package

Based on the above patch.json, .abc quick repair file and .so quick repair file, you can generate the .hqf package through app_packing_tool.jar under the toolchains folder of the local HarmonyOS SDK path. Execute the packaging command as follows:

$ java -jar app_packing_tool.jar --mode hqf --json-path patch.json --lib-path libs --ets-patch patchs --out-path entry-default-unsigned.hqf --force true

Introduction to command line parameters:

Order illustrate Remark
mode model required
json-path patch.json path required
lib-path .so quick repair file path, please refer toquick repair package structure Optional
ets-path .abc quick repair file path Optional

Quick fix package signature

The signature is the same as the hap signature. Use the signature tool to sign the entry-default-unsigned.hqf package generated above. You can use hap-sign-tool.jar in the toolchains folder of the local HarmonyOS SDK path. The command is as follows:

$ java -jar hap-sign-tool.jar sign-app -keyAlias "HarmonyOS Application Release" -signAlg "SHA256withECDSA" -mode "localSign" -appCertFile "HarmonyOSApplication.pem" -profileFile "ohos_provision_release.p7b" -inFile "entry-default-unsigned.hqf" -keystoreFile "HarmonyOS.p12" -outFile "entry-signed-release.hqf" -keyPwd "123456" -keystorePwd "123456"

Install quick fix package

Push the above entry-signed-release.hqf package to the device

hdc.exe file send .\entry-signed-release.hqf /data/

Install the patch package on the device through the following command line

$ bm quickfix -a -f /data/entry-signed-release.hqf

The complete command line reference related to quick repair is as follows:

$ bm quickfix -husage: bm quickfix <options>options list:-h, --help                                   list available commands-q, --query                                  indicates query quickfix, used with -b or --bundle-name-b, --bundle-name <bundle-name>              query quickfix status and information by a specified bundle name-a, --apply                                  indicates apply quickfix, used with -f or --file-path-f, --file-path <file-path>                  apply a quickfix file by a specified path-f, --file-path <file-path> <file-path> ...  apply some quickfix files of one bundle-f, --file-path <bundle-direction>           apply quickfix files by direction, under which are quickfix files

at last

Here is a "Hongmeng Zero Basics Beginner's Study Guide", hoping to provide some help to those who want to learn Hongmeng but have no direction. This document is suitable for beginners in HarmonyOS application development (due to the excessive content of the document, in order to avoid affecting everyone’s reading experience, only part of the content is shown in screenshots. There is a free way to obtain the detailed full version at the end of the article!)

"Hongmeng Zero Basics Beginner's Study Guide"

Table of contents

Insert image description here

1. Quick Start

Suitable for beginners in HarmonyOS application development. By building a simple application with page jump/return function, you can quickly understand the main files of the project directory and become familiar with the HarmonyOS application development process.

  • Development preparation
    • basic concept
    • Tool preparation
  • Building the first ArkTS application (Stage model)
  • Build the first ArkTS application (FA model)
  • Build the first JS application (FA model)

Insert image description here

2. Development of basic knowledge

  • Application package basics
    • Application package overview
    • Application package structure
    • Application package multi-HAP mechanism
    • Application package installation and uninstallation process
    • Application package update process
    • Shared package
    • Application package quick fix
  • Application configuration file (Stage model)
    • Application Profile Overview (Stage Model)
    • app.json5 configuration file
    • module.json5 configuration file
  • Application Profile Overview (FA Model)
    • Application Profile Overview (FA Model)
    • app object internal structure
    • deviceConfig internal structure
    • module object internal structure

Insert image description here

3. Resource classification and access

During application development, resources such as colors, fonts, spacing, and pictures are often used. The values ​​of these resources may be different in different devices or configurations.

  • Resource classification and access
    • Resource classification
    • Resource directory
    • Resource group directory
  • Create resource directories and resource files
    • Create resource directories and resource files
    • Create resource directory
    • Create resource files
  • resource access
    • Application resources
    • system resource
    • Resource matching
      Insert image description here

4. Learn ArkTs language

ArkTS is the preferred main application development language of HarmonyOS. ArkTS has further expanded on the TypeScript (referred to as TS) ecosystem around application development. It inherits all the features of TS and is a superset of TS. Therefore, before learning the ArkTS language, it is recommended that developers have TS language development capabilities.

  • First introduction to ArkTS language
  • basic grammar
    • Basic syntax overview
    • Declarative UI description
    • Custom component
  • Status management
  • Other status management
    • Additional state management overview
    • @Watch decorator: state variable change notification
    • $$ syntax: two-way synchronization of built-in components
  • Rendering controls
    • Rendering controls overview
    • if/else: conditional rendering
    • ForEach: Loop rendering
    • LazyForEach: Lazy loading of data

Insert image description here

Scan the QR code below to get free "Hongmeng 5.0 Zero Basics Beginner's Study Guide"

Guess you like

Origin blog.csdn.net/Android23333/article/details/134891192