A common request about Ionic Appflow builds involves failures related to a build that was previously successful. For example:
Why doesn't my build from yesterday / last week / last month / three months ago build in Appflow successfully today?
Build failures can be caused for a significant number of reasons. However, a build that is run one day is not necessarily the same as a build run at a later time.
Let's examine how your builds can change over time.
Causes of build changes over time
Dependency Changes or Incompatibilities
This is one of the most common causes of build failures and one of the most difficult to troubleshoot. There's an excellent article written by Alexis King that explains the
npm dependency ecosystem in great detail.
A brief summary of the article:
Any of your individual dependencies (and their underlying dependencies) are not guaranteed to be the same in a given project build between now and the next minute/hour/day/week/month/year.
Even minor or patch changes to third party dependencies can have significant impact on your application depending on how you define and make use of your dependencies. This is something that affects all mobile applications - including native applications using other dependency libraries (completely removed from Ionic).
Another potential cause of build failures over time is changes to your build environment or the Ionic Appflow build environment. In relation to Ionic Appflow and your application:
- Node &
npm: Your Node installation can have an effect on your builds; this is particularly true if your project dependencies aren't compatible with your version of NodeJS. This can also be a problem if you are using a different version of Node compared with Ionic Appflow's build environment.
- Cordova: Your versions of
cordova-androidmatter significantly when it comes to building native binaries in Ionic Package. Updating either of those packages can mean the difference between a working build and a broken one. Generally updates to the cordova-platform dependencies are quite stable, but major versions generally end up causing problems with certain third party dependencies.
- JS Framework changes: Over time, changes to Angular (or React or Vue, if those are in your application) can cause your application to have errors. While this technically falls under dependency changes as well, the entirety of Angular - and TypeScript - being updated can have a huge impact on your entire application, so it is worth keeping a watch on it over time.
Future Proofing & Potential Solutions
There are some steps you can take to improve the chances that your "older" builds will still be successful in the future.
Note: The following are suggested as best practices. However, certain actions (like adding your Cordova platform) can result in relative versioning being re-applied to your application's dependencies. Be aware of your app build environment and dependencies at all times!
Explicitly set your dependency versions using a
For starters, there is an excellent article on managing your dependencies here, which includes adding a
.npmrc file to your project. This overrides the
npm default carat so that your versions are set explicitly.
Explicitly set your dependency versions
Removing the carat or tilde in front of your dependencies can be useful to ensure that the main dependency versions are locked in place.
In general, it can be useful to remove any carats or tildes from in front of your dependencies in
// Both of these use relative versioning
Check your dependencies often and thoroughly
This should be obvious, but ensuring that you have up-to-date dependencies can mean the difference between a working app today and a totally broken app tomorrow.
Two commands that can help with identifying outdated dependencies are ionic doctor check and
ionic doctor check runs a series of Ionic-specific checks to ensure your application is formatted in a way that it will generally run with the Ionic CLI and Ionic Appflow.
npm outdated will list your installed dependencies and define the latest version(s) available. You can use this when to determine which dependencies may be outdated.
Note: You should research whether or not your project and other dependencies can safely be updated - there is no guarantee that updating a particular dependency is safe for your application, so be sure to test any changes!
Keep your local environment up-to-date
You can check to ensure your local environment is updated to work in tandem with Ionic Appflow.
Our KB has the most recent build environments denoted in our Build Environment section. Use this in tandem with the
ionic info CLI command to check your local environment versus the Ionic Appflow build environment. They should match (or generally be very close).
You should also ensure - if possible - that you are making use of the most recent versions of
Research your build error(s) and/or try a new build
If you do run into errors running an old build, you should research them and determine where the problem is coming from.
Some suggestions for checking errors:
- Our Knowledgebase: Common errors are documented with solutions in our KB. Try searching for the error string in the search field on the main page and see if you find any articles.
- Google & StackOverflow: Many errors are documented online, so a quick Google search can help immensely!
- Appflow Support: If you can't find a solution to your error from one of the sources above, you can contact us for more assistance.
Finally, one of the best things you can do when facing an error with an old build is to try a new build - preferably a clean build per this document. That can often raise specific issues and help you determine if an outdated dependency may be causing the problem (check to see if the new build has the same error as the old one).