OHOS MyAbilityStage onCreate不打印日志,求解惑?

我按照文档新建了MyAbilityStage,并且在该模块对应的 module.json5中配置如下,但是在预览启动时,log控制台没打印,求解惑
代码如下

import AbilityStage from '@ohos.app.ability.AbilityStage';


export default class MyAbilityStage extends AbilityStage{
  onCreate(): void {
    console.log("MyAbilityStage onCreate")
  }

}

module.json5 如下

{
  "module": {
    "name": "entry",
    "type": "entry",
    "description": "$string:module_desc",
    "mainElement": "MyAbilityStage",
    "srcEntry": "./ets/myabilitystage/MyAbilityStage.ets",
    "deviceTypes": [
      "phone"
    ],
    "deliveryWithInstall": true,
    "installationFree": false,
    "pages": "$profile:main_pages",
    "abilities": [
      {
        "launchType": "singleton",
        "name": "EntryAbility",
        "srcEntry": "./ets/entryability/EntryAbility.ts",
        "description": "$string:EntryAbility_desc",
        "icon": "$media:icon",
        "label": "$string:EntryAbility_label",
        "startWindowIcon": "$media:icon",
        "startWindowBackground": "$color:start_window_background",
        "exported": true,
        "skills": [
          {
            "entities": [
              "entity.system.home"
            ],
            "actions": [
              "action.system.home"
            ]
          }
        ]
      }
    ]
  }
}

求解惑

阅读 359
2 个回答
✓ 已被采纳

已解决 仅预览模式不会触犯,需要模拟器启动才可以

预览模式下不会启动ability,需要在真机或者模拟器运行

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
logo
HarmonyOS
子站问答
访问
宣传栏