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

后端 未结 10 1607
栀梦
栀梦 2020-12-29 01:16

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, therefor

相关标签:
10条回答
  • 2020-12-29 02:01

    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.

    0 讨论(0)
  • 2020-12-29 02:03

    To complement the solution by @Renesaensz, in ionic 4.5.0 (or greater version) add cordova to the commands:

    • ionic cordova platform remove android

    then ionic

    • ionic cordova platform add android
    0 讨论(0)
  • 2020-12-29 02:13

    I had the problem where the app would load most recent changes locally using npm run dev but when I tried to run on my device with cordova run android it would load an old version. I tried all of the suggestions above and nothing worked. I finally figured out that if I did an npm run build before I did the build with cordova to my device, it would load the new version. Hope this helps someone.

    0 讨论(0)
  • 2020-12-29 02:14

    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
    
    0 讨论(0)
提交回复
热议问题