Search code examples
androidangularionic-frameworkionic4capacitor

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


Solution

    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.