Ionic-cli: Cordova not available when using livereload on CLI 3.8.0

Created on 15 Aug 2017  Â·  24Comments  Â·  Source: ionic-team/ionic-cli

After updating to CLI 3.8.0, running in Android device using the command ionic cordova run android -lcs, Cordova plugins does not work. The log shows the following message:

console.warn: Native: tried calling Camera.getPicture, but Cordova is not available. Make sure to include cordova.js or run in a device/simulator

Seems like the issue is when you are trying to run with the livereaload flag. I've tried the following commands:

  • ionic cordova run android --livereload
  • ionic cordova run android -lcs

Only command working is ionic cordova run android.

Plugins tested:

  • Ionic native camera
  • Ionic native geolocation

Steps to reproduce:

  1. Update to CLI 3.8.0
  2. Run your application on Android by using livereload flag
  3. Test Cordova function on device.

Ionic info

@ionic/cli-utils  : 1.8.0
ionic (Ionic CLI) : 3.8.0

global packages:

Cordova CLI : 7.0.1 

local packages:

@ionic/app-scripts : 2.1.3
Cordova Platforms  : android 6.2.3
Ionic Framework    : ionic-angular 3.6.0

System:

Node : v8.2.1
npm  : 5.3.0 
OS   : macOS Sierra
bug

Most helpful comment

Thanks for the thorough bug report, @jayserdny! This one snuck in, unfortunately.

I've published 3.8.1 to fix this issue.

All 24 comments

Thanks for the thorough bug report, @jayserdny! This one snuck in, unfortunately.

I've published 3.8.1 to fix this issue.

@dwieeb Fast and nice work by the way ;) Updating and testing now.

Hi,
What's the command so that I get the consoles on the cli?

@RakeshKB What do you mean? To update the CLI?

@jayserdny
Was curious to know if there is a similar command like in ionic v1.x 'ionic run android -lcs' that we can use in ionic 3.x to get the consoles displayed?
However, I downgraded ionic to 1.7.6 and the issue was fixed for me.

@RakeshKB It does not worth downgrading from 3.x to 1.7.6. Do you want to get console messages running on device or on local system?

@jayserdny
My app is a 1.x one. However, I migrated to 3.x and was facing few issues of which one was the console messages. I would wan't the consoles to be printed on the terminal so that I can check for issues while the app runs on a real device.

@RakeshKB so, you can run your app, ionic run android -l -c -s , then in chrome you can inspect this device to get the logs: chrome://inspect/#devices. Then, select your device and you can see all the logs coming from this device

@jayserdny sure, will do that. Thank you for the quick response :)

@RakeshKB The workaround that @jayserdny mentioned works, but the consolelogs bug for Ionic 1 can be tracked here: https://github.com/ionic-team/ionic-cli/issues/2548

The workaround that @jayserdny mentioned does not work for me.

cli packages: (/usr/local/lib/node_modules)

    @ionic/cli-utils  : 1.19.0
    ionic (Ionic CLI) : 3.19.0

global packages:

    cordova (Cordova CLI) : 8.0.0

local packages:

    @ionic/app-scripts : 3.1.7
    Cordova Platforms  : android 7.0.0
    Ionic Framework    : ionic-angular 3.9.2

System:

    Android SDK Tools : 26.1.1
    Node              : v9.3.0
    npm               : 5.6.0
    OS                : macOS High Sierra
    Xcode             : Xcode 9.2 Build version 9C40b

Environment Variables:

    ANDROID_HOME : /Users/dragon/asdk

Misc:

    backend : pro

Still says cordova not available:

screen shot 2018-01-07 at 2 17 58 am

I'm trying to use the Ionic Native File API. Also happens with the Social Sharing Cordova plugin.

@darkguy2008 are you debugging in the browser on in a real device?

@jayserdny on a real device of course, I wouldn't expect Cordova to work in the browser :P. Without --livereload it works, but there's no livereload. If I enable it, there's livereload but no cordova :(

@darkguy2008 hahaha just in case. But, have you ever tried reinstalling Cordova, Ionic, and maybe the platform you are trying to run on?

I'm getting the same issue with ionic cordova run ios -lcs

cli packages: (/usr/local/lib/node_modules)

    @ionic/cli-utils  : 1.19.0
    ionic (Ionic CLI) : 3.19.0

global packages:

    cordova (Cordova CLI) : 7.1.0 

local packages:

    @ionic/app-scripts : 3.1.4
    Cordova Platforms  : android 6.3.0 ios 4.5.4
    Ionic Framework    : ionic-angular 3.9.2

System:

    Android SDK Tools : 26.1.1
    ios-deploy        : 1.9.2 
    ios-sim           : 6.1.2 
    Node              : v8.9.1
    npm               : 5.5.1 
    OS                : macOS High Sierra
    Xcode             : Xcode 9.2 Build version 9C40b 

Environment Variables:

    ANDROID_HOME : /Users/ben/Library/Android/sdk

Misc:

    backend : pro

cli packages: (/usr/lib/node_modules)

@ionic/cli-utils  : 1.19.1
ionic (Ionic CLI) : 3.19.1

global packages:

cordova (Cordova CLI) : 8.0.0

local packages:

@ionic/app-scripts : 3.1.8
Cordova Platforms  : android 7.0.0 browser 5.0.3
Ionic Framework    : ionic-angular 3.9.2

System:

Android SDK Tools : 26.1.1
Node              : v8.9.4
npm               : 5.6.0 
OS                : Linux 4.13

The same problem here with android and ionic cordova run android --device -lcs

cli packages: (/Users/annetomassoni/Documents/project/node_modules)

    @ionic/cli-utils  : 1.19.1
    ionic (Ionic CLI) : 3.19.1

global packages:

    cordova (Cordova CLI) : 8.0.0

local packages:

    @ionic/app-scripts : 3.1.8
    Cordova Platforms  : android 7.0.0
    Ionic Framework    : ionic-angular 3.9.2

System:

    Android SDK Tools : 26.1.1
    ios-deploy        : 1.9.2
    ios-sim           : 5.0.13
    Node              : v8.9.4
    npm               : 5.6.0
    OS                : macOS High Sierra
    Xcode             : Xcode 9.2 Build version 9C40b

Environment Variables:

    ANDROID_HOME : /Users/annetomassoni/Library/Android/sdk

Misc:

    backend : legacy

Also having the same problem with ionic cordova run android -lc

The original bug has been fixed for months. I'm guessing people who are coming here from google are missing the <script src="cordova.js" ... include in their index.html. Let me know if this is not the case.

Try this
ionic serve --l --c --s

Regards,
RakeshKB

On 31-Jan-2018 22:47, "dwieeb" notifications@github.com wrote:

The original bug has been fixed for months. I'm guessing people who are
coming here from google are missing the