architecture-samples icon indicating copy to clipboard operation
architecture-samples copied to clipboard

Why do you use `minifyEnabled = true` in debug builds?

Open Nimrodda opened this issue 10 years ago • 3 comments

I've been studying these samples, and couldn't help but notice that you're using the new Shrinker in debug builds. I was wondering why? Wouldn't there be performance penalty in build time? And how would it affect debugging and the performance of Instant Run?

In I/O 2016 they showed that by having a "dev" build flavor and setting minSDK to 21, which will enable the new multidexing in ART and make everything faster.

So, a lot of questions and wonderings, it would be so great if you could answer these questions and perhaps add inline comments in build.gradle and explain why you're doing what you're doing, etc.

Thank you for these samples!

Nimrodda avatar Jul 19 '16 06:07 Nimrodda

Yes there can be a performance benefit but your mileage may vary. In our case and in the machines I tried at the time, it was building much faster.

JoseAlcerreca avatar Jul 19 '16 12:07 JoseAlcerreca

It's a trade-off, every project should probably experiment whether it's worth running the shrinker. It does have a build-time cost but it can decrease dexing time and dex2oat (initial startup) time, especially if you have a lot of dependencies.

As for the dev build, Instant Run looks at the target device API level anyway (not the declared min SDK level). It's still a useful trick if you don't/can't use IR for some reason.

bendowski avatar Jul 19 '16 12:07 bendowski

Thanks for the info! :)

Nimrodda avatar Jul 30 '16 04:07 Nimrodda