Is there posibility to run ionic4 app with capacitor on android device with livereload? I was looking for answear for a few hours now without a luck. Please help.
3 Answers
If using a recent version of @ionic/cli
, there is a command now ionic capacitor run android --livereload --external
You can do it manually too (if not using ionic CLI or using an old version that doesn't have the mentioned command) by adding the server object to the capacitor.config.json
file, just use the url of your live reload server
"server": {
"url": "http://192.168.1.33:8100"
}

- 51,328
- 11
- 132
- 176
-
It looks like the cli automatically adds the "server" key and url value to the config file when I run on livereload. Unfortunately, the url changes every so often, which breaks the security features I have in place, specifically cleartextTrafficPermitted exceptions. If I attempt to manually add the url, the cli will add an "original_url" key and value, which disregards my manual entry. Is there any way to ensure that the livereload server will run on the url I specify? – jwBurnside Sep 09 '20 at 14:22
You can use the following command to livereload without specifying the IP address:
ionic capacitor run android --livereload --external
The "--external" flag hosts the development server on all network interfaces (like adding --address=0.0.0.0) [1]. The "--livereload" flag can be shortened to "-l".
After executing the command, open your native IDE and run the app on the device or simulator. You will know that the livereload server is running when you see the message "Using app server http://x.x.x.x:8100" (your IP address).

- 171
- 2
- 7
You can use the ionic
cli for this:
ionic capacitor run android --livereload
For example.
Source: https://ionicframework.com/docs/cli/commands/capacitor-run

- 1,811
- 18
- 20
-
Ionic is not rebuilding the app to `www` or `android` folders. Thus, it is not updating it in the Android Studio and in the Android device. Do you have any idea why? – Wesley Gonçalves Aug 19 '19 at 01:09
-
There may be something else going on if that's the case – does running the above command start the watch server? – Eric Ferreira Aug 20 '19 at 19:03
-
Apparently, it is because in the browser it refreshes the page and updates the content. But the app continues with the old content. Should I enable any feature in the Android Studio? I can't find anything about it on the internet. Thanks for your help – Wesley Gonçalves Aug 20 '19 at 20:54
-
However, if I stop the server and run `ng build` and then restart the server with the command you mentioned, the app gets updated. – Wesley Gonçalves Aug 20 '19 at 20:55
-
That's very strange! The above command should start the livereload server and point the compiled app to it so that the native side points to that. – Eric Ferreira Aug 21 '19 at 00:57