I checked the documentation but didn't find a clear explanation about when to use those commands:
cordova platform add android && cordova run android
cordova prepare android && cordova run android
In the documentations the run
command does this:
Run project (including prepare && compile)
run
is already running prepare
. So, is there any case where I need the option 2? To me it looks like it doesn't make sense if I'm using run
after that.
Thank you in advance for your valuable time : )
Adding a platform in Cordova does not run the prepare
command which will run hook scripts.
platforms/android
and populate it with a complete standalone Android project. Cordova plugins that have been installed will also be installed into the Android project. cordova run android
will run cordova prepare android
followed by cordova build android
, then proceed to install and run the application. If the android platform is already added Cordova will throw and error.cordova prepare android
twice followed by cordova build android
, then install and run that application. If the platform is not added Cordova will throw an error.Conclusion
It makes little sense to differentiate between the two command sequences you provided as they seldom need to be executed. You usually only add a platform once, and you can just call cordova run android
without needing to call cordova prepare android
before it unless you intend to use cordova build android
manually (potentially as a signed release) followed by using adb
or saving/deploying the generated APK without needing to do a full blown run.