简体   繁体   中英

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. Everything is in place and working fine. Due to API 29 support, I'm trying to upgrade Cordova-android platform to v9.0.0. But I'm facing a strange error.

Error:

Unable to load PlatformApi from platform. 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.)

Could not finish All tasks. See reason below

{ Error: Command failed: cordova platform add android@9.0.0 Uncaught, unspecified "error" event. (The platform "android" does not appear to be a valid cordova platform. It is missing API.js. android not supported.)

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. 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:

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".

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:

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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