一个项目包含entry+n个module,无法从entry跳转到module中的ability。理论上应该可以正常执行,不知是否是官方bug?目前可以在entry中跳转library的ability。
操作前提:
1、新建module选择 xxxx ability,完成创建;
2、entry中添加gradle依赖:implementation project(" : xxxx");
3、事件触发,执行intent (跳转失败);
Intent in = new Intent();
Operation operation = new Intent.OperationBuilder()
.withBundleName(getBundleName())
// .withBundleName("com.harmony.myhmdemo")
// .withAbilityName("com.harmony.settingmodule.SettingAbility")
.withAbilityName(SettingAbility.class.getName())
.withDeviceId("")
.build();
in.setOperation(operation);
startAbility(in);
4、设置跳转intent时注意点:
---bundleName为entry--config.json中的bundleName,非package;
---abilityName为module中对应ability路径;
解决步骤:
1、在module的gradle中设置plugin为library,
'com.huawei.ohos.hap' ===> ''com.huawei.ohos.library"
去掉:entryModules : "entry"
2、修改module的config.json
"distro": {
"deliveryWithInstall": true,
"moduleName": "settingmodule",
"moduleType": "har" # 创建module时默认为feature
}