Android livereload not working
See original GitHub issueDescription of the problem:
ionic capacitor run android --livereload
launches Android Studio as expected, and it shows up in the emulator when you run in.
However, when you change the web source, for example home.page.html
, you can observe that Angular compiles but the app is not updated in the emulator.
[ng] ℹ 「wdm」: Compiling...
[ng] Date: 2019-07-26T11:41:55.215Z - Hash: f7a5c98bae47fab75e0d - Time: 844ms
[ng] 103 unchanged chunks
[ng] chunk {home-home-module} home-home-module.js, home-home-module.js.map (home-home-module) 4.92 kB [rendered]
[ng] ℹ 「wdm」: Compiled successfully.
I verified by opening a browser and going to http://localhost:8100
that the source has indeed updated, but it is just not reflected in the Android emulator.
What makes it even stranger is that if I open chrome and inspect (chrome://inspect/#devices
) and force a reload that way, I can see that the Android emulator reloads, but the changes are not reflected. Maybe some sort of Capacitor webview caching issue?
Here’s steps to reproduce:
git clone https://github.com/biesbjerg/capacitor-android-livereload.git
ionic capacitor run android --livereload
- Run in emulator when Android Studio has launched
- Make a change to web source
Affected platform
- Android
- iOS
- electron
- web
OS of the development machine
- Windows
- macOS
- linux
Other information:
Ionic:
Ionic CLI : 5.2.3 (/Users/kim/.npm-global/lib/node_modules/ionic)
Ionic Framework : @ionic/angular 4.7.0
@angular-devkit/build-angular : 0.13.9
@angular-devkit/schematics : 7.3.9
@angular/cli : 7.3.9
@ionic/angular-toolkit : 1.5.1
Capacitor:
Capacitor CLI : 1.1.1
@capacitor/core : 1.1.1
Utility:
cordova-res : 0.6.0
native-run : 0.2.8
System:
NodeJS : v10.15.0 (/usr/local/bin/node)
npm : 6.10.2
OS : macOS Mojave
Issue Analytics
- State:
- Created 4 years ago
- Reactions:1
- Comments:8 (3 by maintainers)
Top GitHub Comments
The problem is that command is setting the server url to localhost, and that makes to load the local assets.
If you run with
ionic capacitor run android -l --address=0.0.0.0
then it will work.I think Ionic CLI is going to be updated to add the --address=0.0.0.0 as default when the run is targeted to android.
Keeping it open because in #1776 we are trying to workaround this problem too, but have in mind that localhost as live reload server url won’t work on real devices unless you enable port forwarding in chrome inspector.
Thanks for the issue! This issue is being locked to prevent comments that are not relevant to the original issue. If this is still an issue with the latest version of Capacitor, please create a new issue and ensure the template is fully filled out.