无法 'ionic cordova build' 找不到钩子 "after_compile" 和 "after_build" 的脚本

Unable to 'ionic cordova build' No scripts found for hook "after_compile" and "after_build"

无法 ionic cordova build android 工作。

信息:

FIRST: 在 npm install 和 global ionic、cordova 和 angular install I 运行 命令之后ionic cordova build android。我在输出中收到此错误:

...
      ember-cli:testing cli: command.validateAndRun +1ms
    The specified command run is invalid. For available options, see `ng help`.
    [ERROR] An error occurred while running subprocess ng.
            
            ng run app:ionic-cordova-build --platform=android exited with exit code 1.
            

SECOND : 运行ning ng run app:ionic-cordova-build --platform=android 解析没有错误,即使它“退出并带有退出代码1" 当 运行宁 'ionic cordova build android'

第三个: 在 运行ning ng run app:ionic-cordova-build --platform=android i 运行 ionic cordova build android 之后并在构建文件夹中没有 apk 的情况下得到了这个结果:

    ...
BUILD SUCCESSFUL in 23s
42 actionable tasks: 42 executed
Command finished with error code 0: /home/art/Documents/obc/platforms/android/gradlew cdvBuildDebug,-b,/home/art/Documents/obc/platforms/android/build.gradle
Built the following apk(s): 
        /home/art/Documents/obc/platforms/android/app/build/outputs/apk/debug/app-debug.apk
No scripts found for hook "after_compile".
No scripts found for hook "after_build".
art@pop-os:~/Documents/obc$ 

我在运行宁ionic cordova build android之前错过了一些步骤吗?

有没有办法强制它 运行 脚本完成?

是否需要将“after_compile”、“after_build”脚本添加到 package.json 文件?

挂钩可以在项目的 config.XML 中使用 <hook> 元素定义,例如:

<hook type="before_build" src="scripts/appBeforeBuild.bat" />
<hook type="before_build" src="scripts/appBeforeBuild.js" />
<hook type="before_plugin_install" src="scripts/appBeforePluginInstall.js" />

<platform name="android">
    <hook type="before_build" src="scripts/android/appAndroidBeforeBuild.bat" />
    <hook type="before_build" src="scripts/android/appAndroidBeforeBuild.js" />
    <hook type="before_plugin_install" src="scripts/android/appAndroidBeforePluginInstall.js" />
    ...
</platform>

构建成功后写入apk文件的路径。在您的日志中找到:

Built the following apk(s): /home/art/Documents/obc/platforms/android/app/build/outputs/apk/debug/app-debug.apk