poetic / ember-cli-cordova

A tool for creating hybrid apps using a combination of ember-cli and cordova
MIT License
441 stars 77 forks source link

Livereload on Android device opens Chrome #174

Closed Mitchal closed 7 years ago

Mitchal commented 8 years ago

Hi and thanks for a potentially awesome addon!

I am trying to get the very interesting-looking livereload feature to work on my Nexus 4 Android device (real device, not emulator). Here is what I do:

  1. ember new hello
  2. cd hello
  3. ember install ember-cli-cordova
  4. In config/environment.js: Rename key locationType to defaultLocationType
  5. ember generate cordova-init com.poeticsystems.hello
  6. Accept the files to be overwritten
  7. cd cordova
  8. cordova platform add android
  9. cd ..
  10. In config/environment.js: Set cordova.liveReload.enabled = true, cordova.liveReload.platform = 'android' and cordova.emberUrl to my ip on the local network
  11. ember cordova:build --platform android
  12. ember serve
  13. In other terminal window, since ember serve is blocking, I do this: ember cordova run android

Expected result: App starts on the device and looks and behaves exactly as before liveReload was enabled, but also gets all changes made in the Ember app immediately without having to rebuild the app.

Actual result: The app starts on the device like normal but also pops open a Chrome browser pointing to the URL specified in cordova.emberUrl in config/environment.js. In the Chrome browser window, a couple of weird prompts show up, and after closing them, the app is frozen and seemingly not fully loaded. Upon closing the Chrome browser window, the Cordova app runs normally but does not respond to changes made to the source, i. e. exactly as before enabling liveReload.

I hope anyone can help me with this! Thanks!

Mitchal commented 8 years ago

Alright, I got it! The browser-opening issue in the emulator was solved by adding this to config.xml: <allow-navigation href="http://10.0.2.2:4200/*" /> I guess I will need another line for each ip-adress my dev machine will have from each device's point of view.

But I still wonder - why is this little 'hack' not mentioned in the docs, and is there a more robust way to deal with it?

nicwillemse commented 7 years ago

Hi @Mitchal, im experiencing this on device as well, did you have to do anything else?

Mitchal commented 7 years ago

Hi @nicwillemse! Sorry to hear you've been struggling with this as well - I know it can be mighty frustrating. Sadly I don't have any further insights in this than I have shared previously, above.

Hope you'll work it out, and please share any solution here for completeness. :-)