I checked the documentation but didn't find a clear explanation about when to use those commands:
cordova platform add android && cordova run androidcordova 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
preparecommand which will run hook scripts.platforms/androidand populate it with a complete standalone Android project. Cordova plugins that have been installed will also be installed into the Android project.cordova run androidwill runcordova prepare androidfollowed bycordova build android, then proceed to install and run the application. If the android platform is already added Cordova will throw and error.cordova prepare androidtwice followed bycordova 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 androidwithout needing to callcordova prepare androidbefore it unless you intend to usecordova build androidmanually (potentially as a signed release) followed by usingadbor saving/deploying the generated APK without needing to do a full blown run.