Skip to content
This repository has been archived by the owner on May 1, 2020. It is now read-only.

cordova plugins are not loaded when running the app on external device with --liverload flag #467

Closed
jgw96 opened this issue Nov 23, 2016 · 30 comments
Assignees

Comments

@jgw96
Copy link
Contributor

jgw96 commented Nov 23, 2016

From @rolandjitsu on November 23, 2016 14:31

Ionic version: (check one with "x")
[ ] 1.x
[x] 2.x

I'm submitting a ... (check one with "x")
[x] bug report
[ ] feature request
[ ] support request => Please do not submit support requests here, use one of these channels: https://forum.ionicframework.com/ or http://ionicworldwide.herokuapp.com/

Current behavior:

It seems like cordova plugins are not loaded when I run the app on an external device with the --livereload flag.

Expected behavior:

I'm not sure if this is intended behaviour, but if it is, it might not be the best idea to only load plugins when the app is run without the flag as I do not want to make requests to my production server when I am actually just testing the app (right now running without the liverload flag it will build for production).
It should load the cordova plugins whenever the app is run on a device.

Steps to reproduce:

Related code:

insert any relevant code here

Other information:

Ionic info: (run ionic info from a terminal/cmd prompt and paste output below):

Cordova CLI: 6.4.0 
Ionic Framework Version: 2.0.0-rc.3
Ionic CLI Version: 2.1.12
Ionic App Lib Version: 2.1.7
Ionic App Scripts Version: 0.0.46
ios-deploy version: Not installed
ios-sim version: Not installed
OS: macOS Sierra
Node Version: v6.7.0
Xcode version: Xcode 8.1 Build version 8B62

Copied from original issue: ionic-team/ionic-framework#9309

@jgw96
Copy link
Contributor Author

jgw96 commented Nov 23, 2016

From @condorman on November 23, 2016 14:53

+1 help!

@mhartington
Copy link
Contributor

Please provide some relevant information, like which plugins you are trying to use, so we can help.

@mhartington
Copy link
Contributor

Also note that certain plugins, especially ones that need access to the device file system will not work with live-reload. Since the source is technically on your computer, and not on the device, it does not have access to the devices file system. So some plugins not working is expected.

@rolandjitsu
Copy link
Contributor

@mhartington none of the plugins are available, cordova.js has just one line of text with something about dev mode.

@mhartington
Copy link
Contributor

how can I reproduce this.

@rolandjitsu
Copy link
Contributor

I was running a app on a Samsung Galaxy Tab with ionic run android --device --livereload and that's about it.

It used to work just fine a few days ago when I ran the app on a Genymotion device though.

"cordovaPlugins": [
	"cordova-plugin-device",
	"cordova-plugin-console",
	"cordova-plugin-whitelist",
	"cordova-plugin-splashscreen",
	"cordova-plugin-statusbar",
	"ionic-plugin-keyboard",
	"ionic-plugin-deploy",
	"cordova-plugin-image-picker",
	"cordova-plugin-camera",
	"cordova-plugin-compat",
	"phonegap-nfc"
]

@condorman
Copy link

the problem is cordova.js don't loaded:

  • ionic start TEST blank --v2
  • cd TEST
  • ionic run android -lc

when you open console from chrome cordova.js not load and so plugins fail.

@mhartington
Copy link
Contributor

thanks @condorman, that's what I was looking for.

Ok, I can confirm this, cordova.js is not being loaded in.

cc @jthoms1

@dejancencelj
Copy link

revert to ionic 2.1.8
start: ionic run android -lc
start in separate cmd: npm run watch
works form me currently with app scripts 0.0.46 & Ionic 2 RC3

@lukasbisdorf
Copy link

lukasbisdorf commented Nov 24, 2016

I am using the SecureStorage, for me this workarround will not work because with the downgrade to 2.1.8 the linking to the plugins seems to be missing.
For me it looks like, that there is something elementary broken in connection with ionic-native and Cordova plugins. Developing the app in the Browser is not sufficient in my case (because of the cordova plugins)

@puffinofdoom
Copy link

@jthoms1 Is there any update on this?

@rolandjitsu
Copy link
Contributor

I think this is fixed with the 0.0.47 release. At least I just updated and it seems to be working.

@jthoms1 jthoms1 closed this as completed Dec 21, 2016
@tskweres
Copy link

I'm seeing this issue with Ionic 3

@distante
Copy link

distante commented Aug 7, 2017

I had the same problem today with a new menu based project. (ionic 3)

@mora260
Copy link

mora260 commented Aug 15, 2017

I'm having exactly the same issue today. After the ionic cli 3.8 update. When working with previous cli everything was working correctly

Edit:

I can confirm that downgrading to cli 3.7.0 solves the issue. So maybe a change made broke something.. I noticed that when running the -lcs option in 3.7.0 gives:

Starting app-scripts server: --livereload --l --consolelogs --c
--serverlogs --s --address 0.0.0.0 --port 8100 --p 8100 --livereload-port
35729 --r 35729 --iscordovaserve --nobrowser - Ctrl+C to cancel

and when running the same thing in 3.8.0 it gives:

Starting app-scripts server: --address 0.0.0.0 --port 8100
--livereload-port 35729 --consolelogs --serverlogs --nobrowser - Ctrl+C to cancel

Hope this helps to solve the problem

@avavricek
Copy link

I just noticed this same issue in 3.8.0

@sekhuat
Copy link

sekhuat commented Aug 15, 2017

I also faced the same issue after update CLI from 3.7.0 to 3.8.0. Please fix it, thanks.

@fttx
Copy link

fttx commented Aug 17, 2017

They've fixed it https://github.com/ionic-team/ionic-cli/blob/master/CHANGELOG.md#381-2017-08-14

@VannaDii
Copy link

VannaDii commented Nov 8, 2017

Still experiencing this.

@Richie765
Copy link

I was trying endlessly every suggestion I could find and nothing worked. Eventually I deleted node_modules/ and platforms/, did npm install and ionic cordova prepare and that solved it. There sure is some weirdness going on inside cordova.

@PuriaRad
Copy link

still have this problem with 3.9.2

@tembra
Copy link

tembra commented Jan 8, 2018

I'm having this problem in Ionic CLI 3.19.0 with Android platform 7.0.0 and Cordova 8.0.0. It only occurs if I use ionic cordova run android -lcs. If I remove -lcs flag it works properly.

I already tried to remove node_modules/, plugins/ and platforms/ folders and then install everything again.

These are the messages that I got from console:

[13:16:51]  console.warn: Native: tried accessing the SQLite plugin but Cordova is not available. Make sure to include cordova.js or run in a device/simulator
[13:16:51]  console.warn: Native: tried calling StatusBar.styleDefault, but Cordova is not available. Make sure to include cordova.js or run in a device/simulator
[13:16:51]  console.warn: Native: tried calling SplashScreen.hide, but Cordova is not available. Make sure to include cordova.js or run in a device/simulator

I analyzed the built apk and the cordova.js inside it is the same of platform folder. So it is not empty nor just one line of text with something about dev mode as @rolandjitsu said.

I also realized that SQLite plugin may not work because it maybe need access to the device file system as @mhartington said? But the other plugins (StatusBar and SplashScreen) also do not work and gives the same message. So none of the plugins is working.

Anyone can help me with this issue?

@hiroki-gota
Copy link

Having the same as @tembra , 3.19.0, that cordova.js is missing when --livereload flag is appended.
Works:
ionic cordova run android --device
Does not work:
ionic cordova run android --device --livereload

@allanpoppe
Copy link

allanpoppe commented Jan 14, 2018

I'm also having the same issue as @tembra and @hiroki-gota, with ionic 3.19.0, cordova-android 7.0.0 and cordova 8.0.0, only with livereload.

@BritoMatheus
Copy link

FIX: You need go to node_modules/@ionic/app-scripts/dist/dev-server/serve-config.js

and replace:

exports.ANDROID_PLATFORM_PATH = path.join('platforms', 'android', 'assets', 'www');

to

exports.ANDROID_PLATFORM_PATH = path.join('platforms', 'android', 'app', 'src', 'main', 'assets', 'www');

I found it here [(https://stackoverflow.com/a/48266685)]. And for me it worked !!

@lemonxtt
Copy link

lemonxtt commented Jan 19, 2018

I have same issue and now it's OK.
tks @BritoMatheus, it's work for me :)
file need to edit: node_modules@ionic\app-scripts\dist\dev-server\serve-config.js
some info: cli 3.19.1, cordova 8.0, Windows_10, android 7.0
command: ionic cordova run android --device --livereload

@allanpoppe
Copy link

Works for me too :)

@hiroki-gota
Copy link

Thanks @BritoMatheus!

@jayserdny
Copy link

@BritoMatheus it solved the problem! Thanks!

@imhoffd
Copy link
Contributor

imhoffd commented Feb 2, 2018

Thanks @BritoMatheus, that is the best workaround we have at the moment, aside from downgrading the Android Cordova platform to 6 (cordova platform add android@6).

Please track the new issue here: #1380

Locking as the new issue is not the same as the original issue.

@ionic-team ionic-team locked and limited conversation to collaborators Feb 2, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests