Android Studio and XCode debugging gives "failed to load resource"

So I have a well-functioning app using Capacitor, Ionic, Stencil andAppflow. When I do a build through AppFlow, the APKs and IPAs work fine.

But when I try to run the app from Android Studio or XCode, whether it is release or debug, I always get a blank screen and the console shows “failed to load resource” for index.js, ionic-global.js and app-globals.js. This effectively means that I can’t debug my app, which is a big problem!

In the past, I’ve eventually managed to fix it by a combination of uninstalling existing versions from my phone, clearing any caches in Android Studio, restarting Android Studio, restarting my phone, etc. But nothing seems to work anymore.

Any ideas?

Ah, fixed it. It related to Stencil, which was somehow caching incorrectly. Using the --no-cache option on stencil’s build fixed it.