简体   繁体   English

Cordova-android v 9.0.0 构建失败。 Cordova android 平台无效。 缺少 API.js

[英]Cordova-android v 9.0.0 build failed. Invalid Cordova android platform. API.js missing

I have been working with Cordova-android@8.1.0 so far.到目前为止,我一直在使用 Cordova-android@8.1.0。 Everything is in place and working fine.一切都到位并且工作正常。 Due to API 29 support, I'm trying to upgrade Cordova-android platform to v9.0.0.由于 API 29 支持,我正在尝试将 Cordova-android 平台升级到 v9.0.0。 But I'm facing a strange error.但我正面临一个奇怪的错误。

Error:错误:

Unable to load PlatformApi from platform.无法从平台加载 PlatformApi。 SyntaxError: Unexpected token ... Uncaught, unspecified "error" event. SyntaxError: Unexpected token ... Uncaught, unspecified "error" event。 (The platform "android" does not appear to be a valid cordova platform. It is missing API.js. android not supported.) (平台“android”似乎不是有效的cordova平台。缺少API.js。不支持android。)

Could not finish All tasks.无法完成所有任务。 See reason below看下面的原因

{ Error: Command failed: cordova platform add android@9.0.0 Uncaught, unspecified "error" event. { 错误:命令失败:cordova 平台添加 android@9.0.0 未捕获、未指定的“错误”事件。 (The platform "android" does not appear to be a valid cordova platform. It is missing API.js. android not supported.) (平台“android”似乎不是有效的cordova平台。缺少API.js。不支持android。)

at ChildProcess.exithandler (child_process.js:206:12)

at emitTwo (events.js:106:13)

at ChildProcess.emit (events.js:191:7)
at maybeClose (internal/child_process.js:877:16)
at Socket.<anonymous> (internal/child_process.js:334:11)
build   at emitOne (events.js:96:13)
at Socket.emit (events.js:188:7)
at Pipe._handle.close [as _onclose] (net.js:498:12)
killed: false,
build
build 
build cmd: 'cordova platform add android@9.0.0' }

I have managed to fix this issue in my Cordova application.我已经在我的 Cordova 应用程序中解决了这个问题。 What happened to me was that I had an old Node.js version, so I could only use Android 7.0.0 with the command:发生在我身上的是我有一个旧的 Node.js 版本,所以我只能通过以下命令使用 Android 7.0.0:

cordova platform add android@7.0.0

Otherwise, I had the same error as yours with the message: "The platform "android" does not appear to be a valid cordova platform. It is missing API.js. android not supported".否则,我遇到了与您相同的错误消息:“平台“android”似乎不是有效的cordova平台。缺少API.js。不支持android”。

However, after upgrading my Node.js to the latest stable version (v14.5.1) with NVM ( https://github.com/nvm-sh/nvm ) and reinstalling the Android platform with the commands:但是,在使用 NVM ( https://github.com/nvm-sh/nvm ) 将我的 Node.js 升级到最新的稳定版本 (v14.5.1) 并使用以下命令重新安装 Android 平台后:

cordova platform rm android

cordova platform add android@9.0.0

My android application now could be built successfully with Cordova and the API 29.我的 android 应用程序现在可以使用 Cordova 和 API 29 成功构建。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM