Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bug: ionic capacitor run android --livereload is not rebuilding the app #4126

Open
ionitron-bot bot opened this issue Aug 19, 2019 · 13 comments
Open

bug: ionic capacitor run android --livereload is not rebuilding the app #4126

ionitron-bot bot opened this issue Aug 19, 2019 · 13 comments
Labels

Comments

@ionitron-bot
Copy link

ionitron-bot bot commented Aug 19, 2019

Original issue by @WesleyGoncalves on 2019-08-19T02:04:10Z

The app is not being updated in the Android device after I make changes to it. The live reload is not working.

The app only gets updated if I run ng build, then ionic capacitor copy android or ionic capacitor run android -l, and then run the app in Android Studio.

@brospars
Copy link

Any update on this ?
I have the same issue (Ubuntu 18.04) ionic-cli compiles when it sees the change but my device is not updated (even if I restart the app)

[ng] 103 unchanged chunks
[ng] chunk {tab2-tab2-module} tab2-tab2-module.js, tab2-tab2-module.js.map (tab2-tab2-module) 4.58 kB  [rendered]
[ng] Time: 1082ms
[ng] ℹ 「wdm」: Compiled successfully.

@imhoffd
Copy link
Contributor

imhoffd commented Sep 30, 2019

@WesleyGoncalves @brospars While running ionic capacitor run android -l, what does capacitor.config.json contain?

@brospars
Copy link

brospars commented Oct 1, 2019

@dwieeb It adds the server url

{
  "appId": "io.ionic.blabla",
  "appName": "blabla-app",
  "bundledWebRuntime": false,
  "npmClient": "npm",
  "webDir": "www",
  "server": {
    "url": "http://localhost:8100"
  }
}

Edit : I've just noticed that even if I rebuild the app in android studio it doesn't update, I have to run without livereload ionic capacitor run android then rebuild it to see the change (even a simple html change)

@alexdev888
Copy link

alexdev888 commented Oct 2, 2019

@brospars

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

  2. Add this to your AndroidManifest.xml in the tag (Tag application already exists)
    <application android:usesCleartextTraffic="true">

  3. Run live reload with host of your PC
    ionic capacitor run android -l --address=192.168.2.106
    INSTEAD OF 192.168.2.106 YOU PUT YOR PC'S ADDRESS

  4. After run Android Studio with connected device as usual

@brospars
Copy link

brospars commented Oct 3, 2019

@alext0101 Just adding my address worked, thank you !
Using <application android:usesCleartextTraffic="true"> wasn't necessary since I'm targeting API level 27

Maybe, this should be added in the documentation

@alexdev888
Copy link

alexdev888 commented Oct 3, 2019

@brospars, how can we add this to the documentation?
In my case, using Android 9, I needed to add this attribute.

@brospars
Copy link

brospars commented Oct 3, 2019

We could update these pages :

The first one gives an example of live reload with cordova but not with capacitor and say it doesn't work with localhost:8100 but you need to provide your host IP address.

We could also say that <application android:usesCleartextTraffic="true"> may be needed for API level > 28

@muttalkadavul
Copy link

We could update these pages :

The first one gives an example of live reload with cordova but not with capacitor and say it doesn't work with localhost:8100 but you need to provide your host IP address.

We could also say that <application android:usesCleartextTraffic="true"> may be needed for API level > 28

Yes this should be documented ! I was stuck for almost a day on this !

@mcelotti
Copy link

mcelotti commented Dec 4, 2019

We could update these pages :

The first one gives an example of live reload with cordova but not with capacitor and say it doesn't work with localhost:8100 but you need to provide your host IP address.

We could also say that <application android:usesCleartextTraffic="true"> may be needed for API level > 28

I got it working with the <application android:usesCleartextTraffic="true"> and command ionic capacitor run android --livereload --external

@chilupa
Copy link

chilupa commented Apr 10, 2020

@brospars

  1. Open android/app/src/main/AndroidManifest.xm
  2. Add this to your AndroidManifest.xml in the tag (Tag application already exists)
    <application android:usesCleartextTraffic="true">
  3. Run live reload with host of your PC
    ionic capacitor run android -l --address=192.168.2.106
    INSTEAD OF 192.168.2.106 YOU PUT YOR PC'S ADDRESS
  4. After run Android Studio with connected device as usual

Don't need to put our PC's address. Just do

  • In Android manifest xml, use android:usesCleartextTraffic="true" in <application>
  • Run ionic capacitor run android -l --external in your ionic app. This should build your app and open your android studio.
  • Click on Run in Android Studio ( Either an emulator or a real device )

It should get your app running :)

@tx-tim
Copy link

tx-tim commented Jul 15, 2020

Battled this for several hours before coming across this issue. I finally got livereload to work on android by following the steps above from @brospars with a slight tweak to step 3.

Instead of

`ionic capacitor run android -l --address=192.168.2.106`

I replaced --address with --host and also included the --external option.

So step 3 is

ionic capacitor run android -l --external --host=192.168.2.106 with your PC's address.

When I omit the host(previously address), I get an error saying ERROR_ADDRESS_UNREACHABLE

@karunt
Copy link

karunt commented Jul 5, 2021

Is there a reason the livereload option doesn't run with ionic capacitor build android? The benefit with using build vs run is that it opens the Android SDK with the code automatically, but an inconvenience if livereload doesn't work with build. Also, I was able to make the livereload option work by just using the --external option; didn't need to specify the host. For reference, I'm using API level 28.

@ajay-gupta25
Copy link

I was facing the similar issue for one of my react-ionic based capacitor project. This was fixed by adding server: {} in capacitor.config.ts file (or capacitor.config.json).

const config: CapacitorConfig = {
     appId: 'io.ionic.starter',
     appName: 'appName',
     webDir: 'build',
     bundledWebRuntime: false,
     server: {
       url: "http://<REPLACE_YOUR_IP_HERE>:8100", // need to replace your IP here
       cleartext: true
     },
};

This works for me, hope works for others too!!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

9 participants