You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

按Apache官方教程新建的Cordova项目执行Android构建失败

Understanding Your Cordova Build Logs

Hey there! Let’s break down those messages you’re seeing when running cordova build android --verbose—most are totally normal, but there’s one line worth noting:

Normal, Expected Messages

  • No scripts found for hook "before_build". No scripts found for hook "before_prepare".
    This is just Cordova letting you know you haven’t set up any custom hook scripts for the before_build or before_prepare stages. Hooks are optional custom scripts you can add to automate tasks during the build process; if you don’t need them, this message is nothing to worry about—it’s just the default behavior.

  • Checking config.xml and package.json for saved platforms that haven't been added to the project
    Cordova automatically syncs platform information between your config.xml (the Cordova-specific config file) and package.json (the standard Node.js project config). This line is just it starting that routine check.

  • Config.xml and package.json platforms are the same. No pkg.json modification.
    Initially, Cordova detects that your platform lists match perfectly, so no changes are needed to package.json.

The Line to Pay Attention To

  • Package.json and config.xml platforms are different. Updating config...
    This means Cordova found a mismatch between the platforms listed in package.json and config.xml right after its initial check. This can happen if you manually edited one of the files, or if a previous platform add/remove operation didn’t fully sync the two files. The good news? Cordova is automatically fixing the mismatch by updating config.xml to align with package.json (or vice versa).

Quick Fix if This Mismatch Keeps Happening

If you keep seeing this message on every build, you can manually sync the files yourself:

  1. Open config.xml and check the <platform> elements (look for <platform name="android">).
  2. Open package.json and check the cordova.platforms array.
  3. Make sure both files list exactly the same platforms (e.g., both include "android").
  4. Run cordova prepare to force a full sync of your project configuration.

内容的提问来源于stack exchange,提问作者Ben Carpenter

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.26 08:53:47