0

I'm, currently trying to optimise my build time of an android application I'm developing. Currently it builds for about a minute and a half initial and about a minute for incremental build. I've tried all the recommendation from this page : https://developer.android.com/studio/build/optimize-your-build#optimize

We just managed to get rid of the annotation processors we previously used, but this does not decrease the initial or incremental build times , just gives us the opportunity to use Instant run - with which we previously had a lot of issues , ex. not hot swapping at all.

We made some profiling and found that more than half of the time is taken from the :app:packageProductionDebug task. Here is a profiler sample of one of my incremental build :

total:                         58s
:app:packageProductionDebug 38.933s 
:app:transformDexArchiveWithDexMergerForProductionDebug 6.697s  
:app:transformClassesWithDexBuilderForProductionDebug   3.833s  
:app:compileProductionDebugJavaWithJavac    2.891s  
:app:transformClassesWithFirebasePerformancePluginForProductionDebug    1.530s  
:app:processProductionDebugResources    1.500s  
:app:compileProductionDebugKotlin   1.478s  

What is this task doing ? I imagine it is only packaging the previously compiled code into apk. If I'm not wrong, why this task takes 80% of the time ? Can I make something in order to improve this ?

user2610355
  • 101
  • 5

1 Answers1

0

So I found what was causing the package task to run so much time . I was having those properties in gradle.properties file

org.gradle.daemon=true
org.gradle.jvmargs=-Xms1024m -Xmx5000m -Xcheck:jni -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8

After removing those properties the package task runs for a second and have overall incremental build time for about 15 seconds. I have no idea why those properties caused such a drastic decrease in the performance of the build , but I don't care, as far as I have 15 seconds build

user2610355
  • 101
  • 5