2
votes

I am trying to remove the Android platform in my cordova app but I am unable. Help is appreciated!

$ cordova platform remove android

rm: could not remove directory (code ENOTEMPTY): myapp\platforms\android/app

rm: could not remove directory (code ENOTEMPTY): myapp\platforms\android/app rm: could not remove directory (code ENOTEMPTY): myapp\platforms\android

Removing platform android from config.xml file...

Not sure why, but I check to see if it is at least recognized as removed but it is not:

$cordova platform

Installed platforms:
android

Available platforms:

android ~7.0.0 browser ~5.0.1 ios ~4.5.4 osx ~4.0.1 windows ~5.0.0 www ^3.12.0

If I go to re-add the android platform I get this:

$ cordova platform add android

Using cordova-fetch for cordova-android@^7.0.0 (node:11012) UnhandledPromiseRejectionWarning: CordovaError: Platform android already added. at C:\Users\computer\AppData\Roaming\npm\node_modules\cordova\node_modules\cordova-lib\src\cordova\platform\addHelper.js:149:35 at _fulfilled (C:\Users\computer\AppData\Roaming\npm\node_modules\cordova\node_modules\cordova-lib\node_modules\q\q.js:787:54) at self.promiseDispatch.done (C:\Users\computer\AppData\Roaming\npm\node_modules\cordova\node_modules\cordova-lib\node_modules\q\q.js:816:30) at Promise.promise.promiseDispatch (C:\Users\computer\AppData\Roaming\npm\node_modules\cordova\node_modules\cordova-lib\node_modules\q\q.js:749:13) at C:\Users\computer\AppData\Roaming\npm\node_modules\cordova\node_modules\cordova-lib\node_modules\q\q.js:557:44 at flush (C:\Users\computer\AppData\Roaming\npm\node_modules\cordova\node_modules\cordova-lib\node_modules\q\q.js:108:17) at _combinedTickCallback (internal/process/next_tick.js:131:7) at process._tickCallback (internal/process/next_tick.js:180:9) (node:11012) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1) (node:11012) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

2
Did u try to delete manually?Ravikumar
I had deleted cordova entirely and reinstalled it to the same error.user5854648
When u cmd cordova platform add android what android version will be adding to project?Ravikumar
I updated my question to show what happens if I try to re-add the Android platform. I am trying to pull whatever latest working android version there is which I always accomplish with cordova platform add androiduser5854648
Delete the platform folder in project and cmd cordova platform add [email protected]Ravikumar

2 Answers

8
votes

I figured this out. I had to use rm instead of remove like so:

cordova platform rm android

Not sure why, would love for someone to elaborate, the cordova docs contain cordova platform remove

0
votes

I encountered a similar problem. The solution was to point away from the android directory in Windows Explorer before removing the platform.