I am getting an error when I add android platform and prepare android.
When I run the following command :-
ionic capacitor add android
I get following error:-
[error] "android" platform already exists. To add a new "android" platform, please remove "D:\ionic\myapp\android" and run this command again. WARNING! your native IDE project will be completely removed. [ERROR] An error occurred while running subprocess capacitor. capacitor.cmd add android exited with exit code 1.
I updated the android by using the following command:-
ionic capacitor update android
It updated my android : -
capacitor.cmd update android √ Updating Android plugins in 73.77ms
Found 0 Capacitor plugins for android: √ update android in 473.61ms Update finished in 0.593s
Then I tried to prepare the android to start in Android studio :-
ionic cordova prepare android
I got the following error:-
cordova.cmd platform add android --save Error: npm: Command failed with exit code 1 Error output: npm ERR! code ENOLOCAL npm ERR! Could not install from "android" as it does not contain a package.json file.
npm ERR! A complete log of this run can be found in: npm ERR!
C:\Users\USER\AppData\Roaming\npm-cache_logs\2020-08-14T09_02_55_668Z-debug.log at ChildProcess.whenDone (C:\Users\USER\AppData\Roaming\npm\node_modules\cordova\node_modules\cordova-common\src\superspawn.js:135:23) at ChildProcess.emit (events.js:223:5) at ChildProcess.cp.emit (C:\Users\USER\AppData\Roaming\npm\node_modules\cordova\node_modules\cross-spawn\lib\enoent.js:34:29) at maybeClose (internal/child_process.js:1021:16) at Process.ChildProcess._handle.onexit (internal/child_process.js:283:5) { stderr: 'npm ERR! code ENOLOCAL\n' + 'npm ERR! Could not install from "android" as it does not contain a package.json file.\n' + '\n' + 'npm ERR! A complete log of this run can be found in:\n' + 'npm ERR! C:\Users\USER\AppData\Roaming\npm-cache\_logs\2020-08-14T09_02_55_668Z-debug.log\n', code: 1 } [ERROR] An error occurred while running subprocess cordova. cordova.cmd platform add android --save exited with exit code 1. Re-running this command with the --verbose flag may provide more information.
I tried to remove cordova and install again. But it is not working.
Have I missed any plugin. I have added the capacitor in the beginning of the project.
Could anyone please suggest any solution ?
ionic cordova prepare android? - Vivek Jain