Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Faster builds on Android - from 2 minutes to 2 ...

Faster builds on Android - from 2 minutes to 2 seconds

What does a developer do when a build takes 2 minutes? He gets bored and his mind starts to wander. Maybe he opens Reddit, Twitter orMedium or checks his emails. Switching context and multitasking kills productivity. Every developer needs fast feedback, so he can jump into the flow state. Therefore, fast builds are essential for productive development.

First, we take a look into Gradle Build Scans. There is no sense in accelerating your build without measuring and comparing the different outcomes. Gradle Build Scans help you to understand what happens during your build and which parts consume the most time.

Then we continue with basic tips to tweak your build with Gradle. Most of those tips are quick wins, because they only require a simple change in the gradle build settings.

Finally, we take a look into how modularisation influences the build speed through an example. By doing it right you can change your business logic and run your tests in 2 seconds instead of 2 minutes.

Philipp Hofmann

April 05, 2019
Tweet

More Decks by Philipp Hofmann

Other Decks in Technology

Transcript

  1. What do you do when you have to wait 2

    minutes? Photo by NordWood Themes on Unsplash
  2. • Measure Your Builds • Quick Wins to Fasten Your

    Builds • Modularisation and Build Speed • Some additional information about the topic on the chart • Maybe some numbers or a background information about some insights • Here is just another placeholder text to visualise the look of a filled info box INFO BOX Topics
  3. $ ./gradlew assembleDebug --scan BUILD SUCCESSFUL in 1s 84 actionable

    tasks: 84 up-to-date Publishing a build scan to scans.gradle.com requires accepting the Gradle Terms of Service defined at https:// gradle.com/terms-of-service. Do you accept these terms? [yes, no]
  4. $ ./gradlew assembleDebug --scan BUILD SUCCESSFUL in 1s 84 actionable

    tasks: 84 up-to-date Publishing a build scan to scans.gradle.com requires accepting the Gradle Terms of Service defined at https:// gradle.com/terms-of-service. Do you accept these terms? [yes, no] yes
  5. $ ./gradlew assembleDebug --scan BUILD SUCCESSFUL in 1s 84 actionable

    tasks: 84 up-to-date Publishing a build scan to scans.gradle.com requires accepting the Gradle Terms of Service defined at https:// gradle.com/terms-of-service. Do you accept these terms? [yes, no] yes Gradle Terms of Service accepted.
  6. $ ./gradlew assembleDebug --scan BUILD SUCCESSFUL in 1s 84 actionable

    tasks: 84 up-to-date Publishing a build scan to scans.gradle.com requires accepting the Gradle Terms of Service defined at https:// gradle.com/terms-of-service. Do you accept these terms? [yes, no] yes Gradle Terms of Service accepted. Publishing build scan...
  7. $ ./gradlew assembleDebug --scan BUILD SUCCESSFUL in 1s 84 actionable

    tasks: 84 up-to-date Publishing a build scan to scans.gradle.com requires accepting the Gradle Terms of Service defined at https:// gradle.com/terms-of-service. Do you accept these terms? [yes, no] yes Gradle Terms of Service accepted. Publishing build scan... https://gradle.com/s/glklref6wdxr6
  8. • Gradle • JVM • Android Studio and SDK Tools

    • Android Plugin for Gradle Update
  9. If neither a task’s inputs nor its output have changed

    since the last time it was run, Gradle will not run it again.
  10. flavorDimensions "mode" productFlavors { dev { dimension "mode" resConfigs "en",

    "xxhdpi" buildConfigField "long", "TIMESTAMP", "0L" } full { dimension "mode" } }
  11. Quick wins 1. Update your Tools 2. Use Instant Run

    3. Caching 4. Incremental Compilation 5. Parallel Builds 6. Build Variant for Develop Photo by Richard R Schünemann on Unsplash
  12. Optimise • Update gradle and gradle plugin • Update Kotlin

    • Enable parallel builds and incremental compilation • Split up code into multiple modules
  13. Build just what you need • Build only the code

    you want to check. • Let you iterate faster on your feature modules.
  14. Advantages of Multiple Modules 1. Build modules in parallel 2.

    Build just what you need 3. Faster Tests 4. And all the other advantages … (Reusability, Maintainability, SOLID, …)
  15. Photo by Richard R Schünemann on Unsplash Quick wins 1.

    Update your tools 2. Use instant run 3. Use Gradle caching 4. Incremental compilation 5. Parallel builds 6. Build variant for develop
  16. Advantages of multiple modules 1. Build modules in parallel 2.

    Build just what you need 3. Faster Tests