fix(apk): 补齐蓝牙模块(aar + dcloud_properties feature)

- libs 增加 Bluetooth-release.aar(从离线 SDK 的 SDK/libs 复制)
- dcloud_properties.xml 增加 <feature name=Bluetooth>,与线上云打包包逐行对齐
- 文档补充:离线打包的模块(aar)处理方式、核对与验证方法
This commit is contained in:
liufumingren 2026-10-02 21:49:14 +08:00
parent 807b545506
commit 1067352c4c
3 changed files with 32 additions and 0 deletions

View File

@ -1,6 +1,7 @@
<properties>
<features>
<feature name="Barcode" value="io.dcloud.feature.barcode2.BarcodeFeatureImpl"/>
<feature name="Bluetooth" value="io.dcloud.feature.bluetooth.BluetoothFeature"/>
<feature name="Maps" value="io.dcloud.js.map.amap.JsMapPluginImpl"/>
<!--<feature name="Maps" value="io.dcloud.js.map.JsMapPluginImpl"/>-->
<feature name="Contacts" value="io.dcloud.feature.contacts.ContactsFeatureImpl"/>

View File

@ -55,6 +55,37 @@ npm run android:pack:raw # 跳过前端编译,仅用现有 dist/build/ap
- **appKey 校验**:`appKey` 与 `appId` + 包名 + 证书 SHA-256 严格绑定,不匹配时 APK 能装能开但启动白屏提示「未配置appkey或配置错误」。详见 `config/README.md`。
- **Runtime 版本提示**:`prepare.cjs` 会把 www 内 `manifest.json`/`app-config-service.js` 的 `compilerVersion` 对齐到 `config/android.json` 的 `runtimeVersion`,用于消除启动时「本应用使用 HBuilderX %s 编译,而手机端 SDK 版本是 %s」的提示。
## 5+ 模块(aar)与 manifest 里勾选的模块
离线打包**不会**自动带上 `src/manifest.json` 里勾选的模块,必须同时满足两个条件:
1. 该模块的 aar 放进 `HBuilder-Integrate-AS/simpleDemo/libs/`;
2. 在 `simpleDemo/src/main/assets/data/dcloud_properties.xml` 里声明对应 `<feature>`。
否则运行时才报错(例如蓝牙会提示「缺少蓝牙模块」,且代码里找不到该文案——它来自 5+ 运行时)。
当前已包含:
| 模块 | 提供物 | 备注 |
|---|---|---|
| Bluetooth(蓝牙打印 / 蓝牙扫码枪) | `libs/Bluetooth-release.aar` + `<feature name="Bluetooth" value="io.dcloud.feature.bluetooth.BluetoothFeature"/>` | 从离线 SDK 的 `SDK/libs/` 复制;本工程最初缺这一项(骨架克隆自不使用蓝牙的项目) |
| Barcode / Camera / File / Storage / Console 等 | `libs/lib.5plus.base-release.aar` | 基础运行时自带 |
| Webview-x5 | 未单独引入 | 已比对线上云打包 APK:其原生库与本工程完全一致(无 X5 专属 so),故保持一致 |
新增其他模块时:到离线 SDK 的 `SDK/libs/` 找同名 aar(命名通常是 `<模块>-release.aar`,如 `geolocation-amap-release.aar`、`share-weixin-release.aar`、`speech-release.aar`),复制到 `libs/`,并在 `dcloud_properties.xml` 增加同名 `<feature>` 行——**类名最快来源是从已发布的云端 APK 里抄**:
```powershell
# 解包云端 APK 后对比两份配置,差异即为缺失的模块声明
# (线上包 assets/data/dcloud_properties.xml vs 本工程同名文件)
```
验证模块是否真的打进包里:
```powershell
tar -xf release\android\wms-pda_v*.apk -C $env:TEMP\apkchk
findstr /m /c:"io/dcloud/feature/bluetooth" $env:TEMP\apkchk\*.dex
```
## 首次使用清单
1. 在 `config/android.json` 填 `appKey`、`keyAlias`、`storePassword`、`keyPassword`(该文件不提交 git);