I have been having this issue for few days now. Cordova won't run in browser, error says browser is not added as a platform. However, trying to add browser as a platform, cause another error which says Unable to load platfromapi from platform. It also says that browser is not a valid platform. See screenshots:
Asked
Active
Viewed 1e+01k times
58
-
My comment will only apply to people trying to dual build a reactjs project: You will get this error if you do not have a `www` folder in your project. – Jacksonkr Mar 11 '20 at 13:09
5 Answers
122
Remove the platform which you try to run on it (browser, ios, android, and etc.)
cordova platform rm browser
Add the platform again
cordova platform add browser
You can run
cordova run browser

Muhammed Tanriverdi
- 3,230
- 1
- 23
- 24
-
1Thanks! This actually worked! It seems that the platform was trying to add/augment an older version of the browser platform (4.1.0 I think). However, when platform rm is used and the platform add is used, the updated browser platform is added (5.0.0) – Ali ArtSharks Oct 19 '17 at 13:07
-
tried adding and removing platform still getting error : Unable to load PlatformApi from platform. Error: Cannot find module '/var/lib/jenkins/workspace/qa_global_php/platforms/.gradle/cordova/Api.js' Failed to install 'mx.ferreyra.callnumber': Error: Uncaught, unspecified "error" event. (The platform ".gradle" does not appear to be a valid cordova platform. It is missing API.js. .gradle not supported.) at EventEmitter.emit (events.js:166:17) at EventEmitter.module.exports.emit (/usr/local/lib/node_modules/cordova/node_modules/cordova-common/src/events.js:71:17) – Ashish Karpe Dec 11 '17 at 14:38
-
at Object.getPlatformApiFunction (/usr/local/lib/node_modules/cordova/node_modules/cordova-lib/src/cordova/util.js:500:20) at Object.getPlatformApi (/usr/local/lib/node_modules/cordova/node_modules/cordova-lib/src/platforms/platforms.js:55:25) at handleInstall (/usr/local/lib/node_modules/cordova/node_modules/cordova-lib/src/plugman/install.js:593:29) at /usr/local/lib/node_modules/cordova/node_modules/cordova-lib/src/plugman/install.js:357:28 at _fulfilled (/usr/local/lib/node_modules/cordova/node_modules/q/q.js:787:54) – Ashish Karpe Dec 11 '17 at 14:38
-
at self.promiseDispatch.done (/usr/local/lib/node_modules/cordova/node_modules/q/q.js:816:30) at Promise.promise.promiseDispatch (/usr/local/lib/node_modules/cordova/node_modules/q/q.js:749:13) at /usr/local/lib/node_modules/cordova/node_modules/q/q.js:509:49 Failed to restore plugin "call-number" from config.xml. You might need to – Ashish Karpe Dec 11 '17 at 14:38
-
try adding it again. Error: Error: Uncaught, unspecified "error" event. (The platform ".gradle" does not appear to be a valid cordova platform. It is missing API.js. .gradle not supported.) Running command: /var/lib/jenkins/workspace/qa_global_php/hooks/after_prepare/010_add_platform_class.js /var/lib/jenkins/workspace/qa_global_php – Ashish Karpe Dec 11 '17 at 14:38
-
Thanks this worked for me! For some reason I had to run the remove command twice before it actually worked properly. – ahb Feb 02 '18 at 14:51
-
8This isn't an acceptable solution for projects that have any native ios changes in their ios platform. – SimpleJ Apr 04 '18 at 18:00
-
2`add` and `remove` does not explain why this error happening and how can we prevent remove the native changes in the platform. – Luigi Lopez Jun 19 '19 at 20:10
2
It looks like the plugin PlatformApi (or what its name is exactly) is not supported by the browser platform.
You can not use the "cordova platform add browser" because the plugin was not written to work with the browser
Maybe it has some specific features that can not be emulated in the browser.

DreamWave
- 1,934
- 3
- 28
- 59
-
4The browser platform was working in the past. It just stopped working few days ago without any indication why. I have been working on my project for few weeks now and I've always tested functionality with the browser platform, until I started getting these errors that is! – Ali ArtSharks Oct 18 '17 at 11:19
2
For those who's still experiencing this issue in latest ionic and cordova versions. Run:
ionic cordova platform rm browser/android/ios
ionic cordova run --emulator

Ronan Boiteau
- 9,608
- 6
- 34
- 56

wobsoriano
- 12,348
- 24
- 92
- 162
-
1Do you know How I could make this work : `ionic cordova platform add android@4.1.1` ... Every time I do this I get `Error: Package name must look like: com.company.Name` even though [widget id](https://stackoverflow.com/a/29147564/6266949) is of the required format – Jason Krs Apr 08 '18 at 20:32
-
people might confuse to run your command inline, it might be separately run, the real parameters was platform rm name/version/URL – Snowbases Aug 07 '19 at 05:16
1
Goto Your android studio
-> tools
-> android
-> Sdk manager
-> Sdk platform
and update Android 7+ and 8+
And then run
cordova platform rm browser
cordova platform add browser

Ahmed Adewale
- 2,943
- 23
- 19
0
i saw this error when i tried to install the android platform that was too high for my current cordova cli, upgrading the cli solved it

Dmitri R117
- 2,502
- 23
- 20