In a recent DevProdEng Showdown! Android gurus from some of the most famous technology and global business brands shared their best tips for accelerating Android build and test feedback cycle times. Here is what our friends at Twitch, JP Morgan Chase, Delta, and Kaiser Permanente had to say.
|“Products only grow bigger over time, so modularize builds to minimize the blast radius of changes. For example, we used to have a module full of highly-interconnected generated GQL code and any changes to this module required a three-minute rebuild and blocked the rest of our app from building. So we created a separate public API module containing interfaces for our GQL APIs. This allowed us to decouple our modules, consuming the APIs from the modules building the generated GQL mutations. We later used the Apollos Multi Module support to parallelize building our generated GQL mutations, further reducing the blast radius of changes.”|
JP Morgan Chase
|“Start with the basics and profile your build. You can do that by profiling how long Gradle takes to execute each phase of the build lifecycle and each build task so you can spot bottlenecks and potentially create tasks for custom build logic and see which ones can run in parallel. Another tip is to consider using static dependency versions rather than dynamic versions because dynamic versions can cause unexpected version updates which makes it difficult to resolve version differences and they can further slow builds since Gradle has to check for updates which by default are cached for only 24 hour.”|
|“Optimize for what you’re actually building on. In our current environment we’re moving to M1 machines. So everything has been optimized for that including moving off of our normal JDK and over to Liberia to get native arm64 support. On top of that, enable your cache and things of that nature. Also, consider reducing the number of agents you’re using to build as opposed to expanding it. This way you can “specialize” what each one is doing and maximize their individual cacheability.”|
|“Modularize, modularize, modularize, and then modularize more. That is by far the best, most productive thing we’ve been able to do. But it has to be independent modules. If you make two modules depend on each other, you will have undone any benefit that you have gained. The other trick that I recently just learned is to make sure all of your JDK instances are the same. So Android Studio and terminal need to point to the same instance. That change actually saved me a lot of time. Also the embedded Java version coming with Android Studio seems to have performance improvements over other versions too.”|
To find out who our live audience thought gave the best tip, watch the video segment below or watch the complete episode to get our panel’s tips on a wider variety of Android developer productivity challenges.