1、鸿蒙上的类似adb的工具名叫hdc

hdc(HarmonyOS Device Connector)是HarmonyOS为开发人员提供的用于调试的命令行工具,通过该工具可以在window/linux/mac系统上与真实设备或者模拟器进行交互。

(1)

hdc list targets

(2)

hdc file send local remote

(3)

hdc install package File

这里列举的几个命令是不是很熟悉?一看名字就知道和安卓中的adb是对应关系。不需要去记忆,在需要使用到的时候去官网查一下就行: hdc使用指导

2、Mac系统配置hdc 环境变量

鸿蒙小知识点_harmonyos

3、项目中的配置文件

安卓中最主要的配置文件是AndroidManifest.xml。 其中定义了版本号,申明了页面路径,注册了广播和服务。并且申明了App使用的权限。 而鸿蒙中也对应有配置文件,但与安卓稍有不同的是鸿蒙分为多个文件。

(1) build-profile.json5 Sdk Version配置在这里, 代码的模块区分也在这里:

{
  "app": {
    "signingConfigs": [],
    "compileSdkVersion": 9,
    "compatibleSdkVersion": 9,
    "products": [
      {
        "name": "default",
        "signingConfig": "default",
      }
    ],
    "buildModeSet": [
      {
        "name": "debug",
      },
      {
        "name": "release"
      }
    ]
  },
  "modules": [
    {
      "name": "entry",
      "srcPath": "./entry",
      "targets": [
        {
          "name": "default",
          "applyToProducts": [
            "default"
          ]
        }
      ]
    }
  ]
}

(2)app.json5 包名,VersionCode,VersionName等信息

{
  "app": {
    "bundleName": "com.example.firstDemo",
    "vendor": "example",
    "versionCode": 1000000,
    "versionName": "1.0.0",
    "icon": "$media:app_icon",
    "label": "$string:app_name"
  }
}

(3)module.json5

模块的详细配置,页面名称和模块使用到的权限在这里申明

{
  "module": {
    "name": "entry",
    "type": "entry",
    "description": "$string:module_desc",
    "mainElement": "EntryAbility",
    "deviceTypes": [
      "phone",
      "tablet"
    ],
    "deliveryWithInstall": true,
    "installationFree": false,
    "pages": "$profile:main_pages",
    "abilities": [
      {
        "name": "EntryAbility",
        "srcEntry": "./ets/entryability/EntryAbility.ts",
        "description": "$string:EntryAbility_desc",
        "icon": "$media:icon",
        "label": "$string:EntryAbility_label",
        "startWindowIcon": "$media:startIcon",
        "startWindowBackground": "$color:start_window_background",
        "exported": true,
        "skills": [
          {
            "entities": [
              "entity.system.home"
            ],
            "actions": [
              "action.system.home"
            ]
          }
        ]
      }
    ],
    "requestPermissions":[
      {
        "name" : "ohos.permission.APPROXIMATELY_LOCATION",
        "reason": "$string:reason",
        "usedScene": {
          "abilities": [
            "FormAbility"
          ],
          "when":"inuse"
        }
      }
    ]
  }
}

4、对应安卓的权限管理

鸿蒙有ATM,ATM(AccessTokenManager)是HarmonyOS上基于AccesssToken构建的统一的应用权限管理能力

5、对应安卓的SharedPreferences能力,鸿蒙有首选项能力

鸿蒙小知识点_鸿蒙开发_02