How to force refresh the cached source files upon

2019-02-04 02:26发布

问题:

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

回答1:

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

ionic platform remove android then ionic platform add android



回答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.



回答3:

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



回答4:

I have deleted android-debug.apk from platforms/android/build/outputs/apk and then ionic cordova run android. It worked with no cache.



回答5:

if you use cordova build, after sudo cordova build <platform>

sudo cordova prepare

at your cordova project root folder.

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



回答6:

Would like to answer this question as it wasted some real valuable time for me.

I emptied the platforms folder and build the solution again. BTW, I am using Visual Studio for development. And I should solve the problem.

Also it is quite obvious but still wanted to reiterate that platforms should not be part of source control.

Hope it helps.



回答7:

Remove platform : ionic cordova platform rm android

Re add platform : ionic cordova platform add android

Step 1) ionic cordova prepare android // copy www folder specific platform

Step 2) ionic cordova build android // build apk

Step 3) ionic cordova run android // deploy latest apk in device



回答8:

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.