1通贞、鴻蒙上的類似adb的工具名叫hdc
hdc(HarmonyOS Device Connector)是HarmonyOS為開發(fā)人員提供的用于調(diào)試的命令行工具,通過該工具可以在window/linux/mac系統(tǒng)上與真實(shí)設(shè)備或者模擬器進(jìn)行交互。
(1)
hdc list targets
(2)
hdc file send local remote
(3)
hdc install package File
這里列舉的幾個(gè)命令是不是很熟悉?一看名字就知道和安卓中的adb是對應(yīng)關(guān)系改备。不需要去記憶,在需要使用到的時(shí)候去官網(wǎng)查一下就行: hdc使用指導(dǎo)
2蔓倍、Mac系統(tǒng)配置hdc 環(huán)境變量
3悬钳、項(xiàng)目中的配置文件
安卓中最主要的配置文件是AndroidManifest.xml。 其中定義了版本號偶翅,申明了頁面路徑默勾,注冊了廣播和服務(wù)。并且申明了App使用的權(quán)限聚谁。
而鴻蒙中也對應(yīng)有配置文件母剥,但與安卓稍有不同的是鴻蒙分為多個(gè)文件。
(1) build-profile.json5
Sdk Version配置在這里形导, 代碼的模塊區(qū)分也在這里:
{
"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
模塊的詳細(xì)配置朵耕,頁面名稱和模塊使用到的權(quán)限在這里申明
{
"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炫隶、對應(yīng)安卓的權(quán)限管理
鴻蒙有ATM,ATM(AccessTokenManager)是HarmonyOS上基于AccesssToken構(gòu)建的統(tǒng)一的應(yīng)用權(quán)限管理能力