成人免费xxxxx在线视频软件_久久精品久久久_亚洲国产精品久久久_天天色天天色_亚洲人成一区_欧美一级欧美三级在线观看

跟著小白一起學鴻蒙—如何編譯Hap程序(十七)

系統 OpenHarmony
本篇我們來學習如何在鴻蒙環境下編譯Hap程序。

??想了解更多關于開源的內容,請訪問:??

??51CTO 開源基礎軟件社區??

??https://ost.51cto.com??

安裝使用說明(Open-Harmony)

在開源鴻蒙系統下

  • 藍牙專項應用程序路徑為:foundation/communication/bluetooth/test/example/BluetoothTest
  • 目錄結構
.
├── example
├── BluetoothTest
├── build-profile.json5
├── hvigorfile.js
├── package.json
├── package-lock.json
├── BUILD.gn
├── entry/src/main
├── config.json
├── ets
├── Component
├── MainAbility
├── app.ets
├── controller
├── model
├── pages
└── res
└── image
├── MainAbility2
└── Utils
└── resources
└── base
├── element
└── media
└── signature
├── fuzztest
├── moduletest
└── unittest
  • 在開源鴻蒙下的編譯,是套用了原本系統中編寫好的hap程序編譯模板,因此保留了一些模板中的結構,如:MainAbility2 和config.json中的js語句;對程序本身的編譯沒有影響。
  • 在bundle.json中添加編譯命令。
路徑為:foundation/communication/bluetooth/bundle.json
命令為:
"test": [
...
"http://foundation/communication/bluetooth/test/example/example_btTest:BluetoothTest"
]
  • 添加BUILD.gn
foundation/communication/bluetooth/test/example/BluetoothTest/BUILD.gn
import("http://test/xts/tools/build/suite.gni")
ohos_hap("BluetoothTest") {
hap_profile = "entry/src/main/config.json"
hap_name = "BluetoothTest"
subsystem_name = XTS_SUITENAME
final_hap_path =
"${SUITES_OUTPUT_ROOT}/${XTS_SUITENAME}/testcases/${hap_name}.hap"
deps = [
":bluetooth_resources",
":bluetooth_ts_assets",
]
certificate_profile = "signature/auto_ohos_default_com.ohos.bttest.p7b"
}

ohos_js_assets("bluetooth_ts_assets") {
source_dir = "entry/src/main/ets"
hap_profile = "entry/src/main/config.json"
ets2abc = true
}

ohos_resources("bluetooth_resources") {
sources = [ "entry/src/main/resources" ]
hap_profile = "entry/src/main/config.json"
}
  • 創建signature文件夾,添加簽名文件。

路徑為:foundation/communication/bluetooth/test/example/example_btTest/signature
簽名文件為:Dev-Eco自動簽名生成的文件:auto_ohos_default_com.ohos.bttest.p7b

  • config.json
{
"app": {
"vendor": "samples",
"bundleName": "ohos.samples.bttest",
"version": {
"code": 1000000,
"name": "1.0.0"
},
"apiVersion": {
"compatible": 8,
"target": 8
}
},
"deviceConfig": {},
"module": {
"mainAbility": ".MainAbility",
"deviceType": [
"default",
"phone"
],
"reqPermissions": [
{
"reason": "",
"name": "ohos.permission.DISCOVER_BLUETOOTH"
},
{
"reason": "",
"name": "ohos.permission.USE_BLUETOOTH"
},
{
"name": "ohos.permission.LOCATION"
}
],
"abilities": [
{
"skills": [
{
"entities": [
"entity.system.home"
],
"actions": [
"action.system.home"
]
}
],
"orientation": "unspecified",
"visible": true,
"srcPath": "MainAbility",
"name": ".MainAbility",
"srcLanguage": "ets",
"icon": "$media:icon",
"description": "$string:MainAbility_desc",
"formsEnabled": false,
"label": "$string:MainAbility_label",
"type": "page",
"launchType": "singleton"
},
{
"orientation": "unspecified",
"visible": true,
"srcPath": "MainAbility2",
"name": ".MainAbility2",
"srcLanguage": "ets",
"icon": "$media:icon",
"description": "$string:MainAbility2_desc",
"formsEnabled": false,
"label": "$string:MainAbility2_label",
"type": "page",
"launchType": "singleton"
}
],
"distro": {
"moduleType": "entry",
"installationFree": false,
"deliveryWithInstall": true,
"moduleName": "entry"
},
"package": "ohos.samples.bttest",
"srcPath": "",
"name": ".entry",
"js": [
{
"mode": {
"syntax": "ets",
"type": "pageAbility"
},
"pages": [
"pages/homePage",
"pages/manualApiTestPage",
...
],
"name": ".MainAbility",
"window": {
"designWidth": 720,
"autoDesignWidth": false
}
},
{
"mode": {
"syntax": "ets",
"type": "pageAbility"
},
"pages": [
"pages/index"
],
"name": ".MainAbility2",
"window": {
"designWidth": 720,
"autoDesignWidth": false
}
}
]
}
}
  • 編譯命令

# 全量編譯
./build.sh --product-name {product_name}

# 單獨編譯HAP
./build.sh --product-name {product_name} --build-target BluetoothTest

  • 生成文件
  • 使用 find out -name “BluetoothTest.hap*” 查找生成文件,或者直接查看config.json所寫的生成路徑。
  • 將生成文件拷到本地電腦上,連接板子,使用命令hdc_std.exe install BluetoothTest進行安裝。
  • 使用命令hdc_std uninstall {安裝包名} 進行卸載。
  • 安裝包名在entry\src\main\config.json 如:"bundleName": "com.ohos.bttest"
  • 補充
    在鴻蒙系統下編譯,仍存在高版本對低版本的編譯不兼容性問題。即在mater版本下編譯的hap無法在beta2版本運行;反之則可以。
  • 可能出現的編譯報錯
  • 一些屬性必須初始化一個默認值。如:The @State property ‘bgColor’ ‘settingArrow’ ‘settingSummary’ must be specified a default value。
  • 注意引用路徑中的文件名大小寫問題。
  • 一些屬性名與關鍵詞或類名重復會起沖突。如:Property ‘height’/“onClick”/“enabled” in type ‘EntryComponent’ is not assignable to the same property in base type 'CustomComponent。將其改成例如"isOnClick"/"isEnabled"即可。
  • 一些資源,如:@State settingSummary: Resource 必須是resource 不能加 |string 或者賦值為string。Type ‘Resource’ is not assignable to type ‘string’. 反之同理。Type ‘string’ is not assignable to type ‘Resource’。

??想了解更多關于開源的內容,請訪問:??

??51CTO 開源基礎軟件社區??

??https://ost.51cto.com??。

責任編輯:jianghua 來源: 51CTO開源基礎軟件社區
相關推薦

2022-12-06 15:39:16

鴻蒙主干代碼

2022-12-02 14:20:09

Tetris鴻蒙

2022-11-29 16:35:02

Tetris鴻蒙

2022-12-09 15:34:38

2023-03-30 09:32:27

2022-11-14 17:01:34

游戲開發畫布功能

2022-11-25 16:48:54

鴻蒙Stage HAP

2023-04-04 09:24:11

鴻蒙HiDumper

2022-10-10 14:47:04

藍牙應用鴻蒙

2023-02-27 16:30:32

鴻蒙開源協議分析

2022-08-19 19:02:20

開源鴻蒙操作系統

2023-03-30 09:19:54

SELinux安全子系統

2022-09-30 14:08:26

Hap應用鴻蒙

2023-01-03 15:09:10

鴻蒙常用工具

2022-08-29 17:25:19

鴻蒙應用開發

2023-03-15 16:19:03

BinderIPC工具

2022-10-09 15:05:50

NAPI框架鴻蒙

2022-10-20 16:40:16

JS應用控制LED鴻蒙

2022-10-17 14:29:24

鴻蒙應用開發

2023-04-06 09:18:52

鴻蒙AVPlayerAVRecorder
點贊
收藏

51CTO技術棧公眾號

主站蜘蛛池模板: 国产精品久久久久久久久久久久 | 97色免费视频 | 91福利网址 | 黄网站免费观看 | 人人叉 | 久久精品国产一区二区 | 99精品99| 免费一级欧美在线观看视频 | 黄色一级毛片免费看 | 一区二区三区电影网 | 久久91精品国产一区二区三区 | 国产激情视频在线 | 97日日碰人人模人人澡分享吧 | 欧美极品在线 | 国产精品久久久久久久久久久久冷 | 九九综合 | 国产农村一级国产农村 | 国产在线精品一区二区三区 | 人妖一区 | 亚洲国产视频一区二区 | 日日碰狠狠躁久久躁婷婷 | 精品美女视频在线观看免费软件 | 欧美最猛黑人xxxⅹ 粉嫩一区二区三区四区公司1 | 久久久久亚洲精品 | 久久久久亚洲视频 | 99精品久久久久久中文字幕 | 久久av一区二区三区 | 久久亚洲欧美日韩精品专区 | av日韩在线播放 | 国产精品无 | 久久精品国产久精国产 | 九九精品在线 | 中文区中文字幕免费看 | 国产精品视频偷伦精品视频 | 国产精品一区二区欧美黑人喷潮水 | 久久人人网 | 色网在线观看 | 日韩精品一区二区三区 | 国产欧美日韩一区二区三区在线观看 | 91精品国产色综合久久不卡98 | 中文字幕一区二区三区四区五区 |