ionic-team / ionic-app-scripts

App Build Scripts for Ionic Projects
http://ionicframework.com/
MIT License
608 stars 304 forks source link

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

Closed jgw96 closed 7 years ago

jgw96 commented 8 years ago

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: driftyco/ionic#9309

jgw96 commented 8 years ago

From @condorman on November 23, 2016 14:53

+1 help!

mhartington commented 8 years ago

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

mhartington commented 8 years ago

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 commented 8 years ago

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

mhartington commented 8 years ago

how can I reproduce this.

rolandjitsu commented 8 years ago

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 commented 8 years ago

the problem is cordova.js don't loaded:

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

mhartington commented 8 years ago

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

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

cc @jthoms1

dejancencelj commented 8 years ago

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 commented 8 years ago

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 commented 7 years ago

@jthoms1 Is there any update on this?

rolandjitsu commented 7 years ago

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

tskweres commented 7 years ago

I'm seeing this issue with Ionic 3

distante commented 7 years ago

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

mora260 commented 7 years ago

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 commented 7 years ago

I just noticed this same issue in 3.8.0

sekhuat commented 7 years ago

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

fttx commented 7 years ago

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

VannaDii commented 7 years ago

Still experiencing this.

Richie765 commented 7 years ago

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 commented 6 years ago

still have this problem with 3.9.2

tembra commented 6 years ago

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 commented 6 years ago

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 commented 6 years ago

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 commented 6 years ago

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 commented 6 years ago

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 commented 6 years ago

Works for me too :)

hiroki-gota commented 6 years ago

Thanks @BritoMatheus!

jayserdny commented 6 years ago

@britoMatheus it solved the problem! Thanks!

imhoffd commented 6 years ago

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: https://github.com/ionic-team/ionic-app-scripts/issues/1380

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