Ionic-cli: The run / build command has been renamed

Created on 6 May 2017  Â·  16Comments  Â·  Source: ionic-team/ionic-cli

I saw a different closed issue that was similar but the fix didn't work for me. :(

What version of the CLI are you using? Output of ionic --version

3.0.0-rc.2

Short description of the problem:

Running ionic run android --device produces error message

The run command has been renamed. To find out more, run:

  ionic cordova run --help

What behavior are you expecting?

Build app for production

Steps to reproduce:

  1. ionic run android --device

Post the output of ionic info below please

global packages:

    @ionic/cli-utils : 1.0.0-rc.2
    Cordova CLI      : 6.5.0 
    Ionic CLI        : 3.0.0-rc.2

local packages:

    @ionic/app-scripts              : 1.3.4
    @ionic/cli-plugin-cordova       : 1.0.0-rc.2
    @ionic/cli-plugin-ionic-angular : 1.0.0-rc.2
    Ionic Framework                 : ionic-angular 3.1.1

System:

    Node       : v7.9.0
    OS         : macOS Sierra
    Xcode      : not installed
    ios-deploy : not installed
    ios-sim    : not installed

Most helpful comment

This command has worked for me
ionic cordova run android --device

All 16 comments

According to the new doc, Cordova commands has been namespaced and put into a CLI plugin.
run npm i --save @ionic/cli-plugin-cordova to install it in your project and then run ionic cordova run android to build your app.

Source:
https://github.com/driftyco/ionic-cli/blob/v3/README.md

This command has worked for me
ionic cordova run android --device

Thank you @ricardo-mello , @reviloera !!

You can try this command

  • ionic cordova platform add android
    or
  • ionic cordova platform add ios

You should try
$ionic cordova run android --device
In most cases, the commands are updated and we just need to write the word 'cordova' after ionic.
Ex: _ionic build android_ does not work rather , _$ionic cordova build android_ works best.

Full command instructions can be displayed with the --help flag: ionic cordova platform --help

I wonder why don't write it on the changelog...

@pimol It's been in the changelog for a while: https://github.com/ionic-team/ionic-cli/blob/master/CHANGELOG.md#additional-changes Also the readme: https://github.com/ionic-team/ionic-cli#changes-from-cli-2

Live reload not work with ionic cordova emulate ios --lc. Any idea ?

cordova platform add android --nofetch cordova run cordova build
if you are using mac to run ios
cordova platform add ios --nofetch cordova run cordova build
i hope this works for you

Why did they change this? 😡

@RoelRoel We changed it because as Ionic and the web grow, the marriage of our CLI to Cordova seems less and less necessary. We see people using Ionic in progressive web apps, web applications, and desktop applications. We felt is was the right move for us going forward not to tie these commands to Cordova directly, but namespace them so other users aren't confused why ionic build makes a Cordova app when they're building for electron, etc.

Has the command changed as well when signing a release?

This doesn't pop up the small Java window asking for the key store password when not passing it trough the command line.
https://cordova.apache.org/docs/en/latest/guide/platforms/android/index.html#signing-an-app

ionic cordova build android --prod --release -- --keystore=filename.keystore --alias=myalias

Looks like the double -- are being ignored:

...
[21:51:24]  build prod finished in 65.39 s
> cordova build android --keystore=filename.keystore --alias=myalias --release
✔ Running command - done!
ANDROID_HOME=/Users/myuser/Library/Android/sdk
...

The -- isn't being ignored. You have to add an additional one because the Cordova command is being wrapped.

Try:

ionic cordova build android --prod --release -- -- --keystore=filename.keystore --alias=myalias

There are additional examples in ionic cordova build --help, but I should add an example for using the command with --keystore options.

@dwieeb awesome! thanks so much

For ionic 3, the following commands worked for me:

Add platform:
$ cordova platform add android

To run on emulator:
$ ionic cordova run android --emulator

To run on device:
$ ionic cordova run android --device

Was this page helpful?
0 / 5 - 0 ratings