How to force refresh the cached source files upon Ionic build/run?

102,093

Solution 1

What I did to solve my problem was to do re-initialize the Android platform.

ionic cordova platform remove android then ionic cordova platform add android

goto task manager and kill java se process

Solution 2

You need to increment your app version on your config.xml (at the top of your project folder) to reflect your changes before running:

<widget id="com.yourapp.id" version="0.0.8" xmlns="http://www.w3.org/ns/widgets" xmlns:cdv="http://cordova.apache.org/ns/1.0"

On this example, increment the attribute version to 0.0.9: version="0.0.9".

Then run android or run ios.

Solution 3

Remove platform :

ionic cordova platform rm android

Re add platform :

ionic cordova platform add android

Step 1) copy www folder specific platform

ionic cordova prepare android

Step 2) build apk

ionic cordova build android

Step 3) deploy latest apk in device

ionic cordova run android

Solution 4

If you use cordova build, sudo cordova build <platform>

sudo cordova prepare

at your cordova project root folder.

this command reflects your changes to builds(all platforms).

Solution 5

This might be a bug with Ionic, but to fix it usually I just ctrl+c then gulp and then re-run ionic serve.

Share:
102,093

Related videos on Youtube

Rene Padillo
Author by

Rene Padillo

A Schemer | Software Engineer | Front-End Web Developer

Updated on March 24, 2022

Comments

  • Rene Padillo
    Rene Padillo about 2 years

    I have this random issue with ionic build or ionic run.

    I've noticed that during compilation it uses the cache of my source code, therefore when making new changes it doesn't reflect upon re-compiling the app.

    So my question is, how can you clear the cache for the build files? I've tried doing ionic state reset but still it doesn't work nor doing uninstall then re-install the app from my Android.

    Thanks

    • Swapnil Shende
      Swapnil Shende over 8 years
    • Rene Padillo
      Rene Padillo over 8 years
      @SwapnilShende I think this isn't a duplicate question, because my issue is with the Ionic build not with views.
    • InfinitePrime
      InfinitePrime over 8 years
      Does this really happen? I am not sure on this. If you can reproduce it, then open an issue on github
    • Rene Padillo
      Rene Padillo over 8 years
      @InfinitePrime yes, I'm stuck with the build for an hour already, I've doubled check everything but it seems it's using a cached source files upon building. I'll try to investigate on how to reproduce the problem.
    • Sandy
      Sandy over 7 years
      @InfinitePrime Yes it really happens. All of a sudden it started happening in my ionic. And no matter what I do, clear browser history, restart IIS and all crazy stuff, my ionic is stuck with 2 days old changes.
    • dbinott
      dbinott almost 7 years
      2 years and this still seems like an issue because it is happening to me. What's the point of live reload if it doesn't reload? To have to reinit the platform each time is ludicrous.
    • Khurshid Ansari
      Khurshid Ansari about 6 years
      in which platform are you facing this problem. I think you are facing problem in ios.
  • Ratata Tata
    Ratata Tata over 7 years
    the fast way, if you are changing something on the config.xml.
  • jonan.pineda
    jonan.pineda over 6 years
    in ionic 2 use ionic cordova platform update android
  • LavenPillay
    LavenPillay almost 6 years
    For ionic 3 i used : ionic cordova platform remove android ionic cordova platform add android<br>
  • Simão Garcia
    Simão Garcia over 5 years
    I've solved a similiar problem in Ionic V3 with: cordova clean
  • Yudhistira Bayu
    Yudhistira Bayu over 5 years
    I've run remove and add platform won't work, and this is the only solution work if remove and add platform wont change anything
  • Patrick Kenny
    Patrick Kenny about 2 years
    This also works for pwa build problems, not just Android and iOS.