pratik jaiswal
pratik jaiswal

Reputation: 2065

Ionic capacitor live reload not working on android

I am using the following command to perform live reloading on android

ionic capacitor run android --livereload --external

But it is not working.

Here is the error I am getting

The web page at http://localhost:8100/ could not be loaded because

net : ERR_CONNECTION_REFUSED

I know that mobile devices don't understand localhost but I thought --external flag will take care of it. Now what I have to do to get live reloading working on android.

Thank you in advance

Upvotes: 2

Views: 5998

Answers (4)

Mohamad Hossein Malek
Mohamad Hossein Malek

Reputation: 11

I had same issue and I tried everything but at the end it was the McAfee Firewall was enabled by my company IT on every laptop! disabling that solved this issue! (I found out when I build an app with latest ionic/Capacitor) and saw that same issue happening.

PS: I was using Android Emulator (not a real device)

Upvotes: 1

Mahdi Zarei
Mahdi Zarei

Reputation: 7396

  1. Open android/app/src/main/AndroidManifest.xml.

  2. Add this to your AndroidManifest.xml in the tag (Tag application already exists):

  • <application android:usesCleartextTraffic="true"> may be needed just for API level > 28.
  1. Run live reload with the host of your PC.
ionic capacitor run android -l --host=127.0.0.1

INSTEAD OF 127.0.0.1 YOU PUT YOUR PC'S IP ADDRESS.

  1. After run Android Studio with a connected device as usual.

Upvotes: 5

en my case i put this in capacitor.config.json

 {
"appId": "io.ionic.starter",
"appName": "medClinicApp",
"webDir": "www",
"bundledWebRuntime": false,
"cordova": {},
"server": {
  "url": "http://192.168.1.6:8100",
  "cleartext": true
 }
}

then run this command ionic cap run android -l --external and the most important is that I disable my firewall.

Upvotes: 4

Mark Phillips
Mark Phillips

Reputation: 21

I have a similar problem, however, it has some different issues.

Live reload works on one tablet using android:usesCleartextTraffic="true" Android 5, but not on my new Samsung running Android 10. So apparently cleartext=true doesn't work in all cases. I know it's not Android studio or my laptop setup, since it serves to one device.

On the Samsung (Android 10) I can run the app itself, without live reload localhost, but when trying to put in debug mode it fails. I can also run the app in the browser of the Samsung using http://localhost:4200

I have been looking through a lot of threads, I thought I'd add it in here in case I find a solution or someone else has an idea for an alternative answer to this problem.

Upvotes: 1

Related Questions