3 min readSep 14, 2017
Hi Fery. Great question. The Android Gradle plugin generates a dependent task for each compile-time dependency as seen here using task-tree plugin.
$ ./gradlew :app:testDebug :app:taskTree --no-repeat------------------------------------------------------------Project :app------------------------------------------------------------:app:testDebugUnitTest+--- :app:assembleDebugUnitTest| +--- :app:compileDebugUnitTestSources| | +--- :app:compileDebugUnitTestJavaWithJavac| | | +--- :app:compileDebugJavaWithJavac| | | | +--- :app:generateDebugSources| | | | | +--- :app:compileDebugAidl| | | | | | \--- :app:prepareDebugDependencies| | | | | | +--- :app:checkDebugManifest| | | | | | | \--- :app:preDebugBuild| | | | | | | \--- :app:preBuild| | | | | | +--- :app:preDebugBuild *| | | | | | +--- :app:prepareComAndroidSupportAnimatedVectorDrawable2600Alpha1Library| | | | | | | +--- :app:preDebugBuild *| | | | | | | \--- :app:preReleaseBuild| | | | | | | \--- :app:preBuild *| | | | | | +--- :app:prepareComAndroidSupportAppcompatV72600Alpha1Library| | | | | | | +--- :app:preDebugBuild *| | | | | | | \--- :app:preReleaseBuild *| | | | | | +--- :app:prepareComAndroidSupportConstraintConstraintLayout102Library| | | | | | | +--- :app:preDebugBuild *| | | | | | | \--- :app:preReleaseBuild *| | | | | | +--- :app:prepareComAndroidSupportDesign2600Alpha1Library| | | | | | | +--- :app:preDebugBuild *| | | | | | | \--- :app:preReleaseBuild *| | | | | | +--- :app:prepareComAndroidSupportRecyclerviewV72600Alpha1Library| | | | | | | +--- :app:preDebugBuild *| | | | | | | \--- :app:preReleaseBuild *| | | | | | +--- :app:prepareComAndroidSupportSupportCompat2600Alpha1Library| | | | | | | +--- :app:preDebugBuild *| | | | | | | \--- :app:preReleaseBuild *| | | | | | +--- :app:prepareComAndroidSupportSupportCoreUi2600Alpha1Library| | | | | | | +--- :app:preDebugBuild *| | | | | | | \--- :app:preReleaseBuild *| | | | | | +--- :app:prepareComAndroidSupportSupportCoreUtils2600Alpha1Library| | | | | | | +--- :app:preDebugBuild *| | | | | | | \--- :app:preReleaseBuild *| | | | | | +--- :app:prepareComAndroidSupportSupportFragment2600Alpha1Library| | | | | | | +--- :app:preDebugBuild *| | | | | | | \--- :app:preReleaseBuild *| | | | | | +--- :app:prepareComAndroidSupportSupportMediaCompat2600Alpha1Library| | | | | | | +--- :app:preDebugBuild *| | | | | | | \--- :app:preReleaseBuild *| | | | | | +--- :app:prepareComAndroidSupportSupportV42600Alpha1Library| | | | | | | +--- :app:preDebugBuild *| | | | | | | \--- :app:preReleaseBuild *| | | | | | +--- :app:prepareComAndroidSupportSupportVectorDrawable2600Alpha1Library| | | | | | | +--- :app:preDebugBuild *| | | | | | | \--- :app:preReleaseBuild *| | | | | | \--- :app:prepareComAndroidSupportTransition2600Alpha1Library| | | | | | +--- :app:preDebugBuild *| | | | | | \--- :app:preReleaseBuild *| | | | | +--- :app:compileDebugRenderscript| | | | | | +--- :app:checkDebugManifest *| | | | | | \--- :app:prepareDebugDependencies *| | | | | +--- :app:generateDebugBuildConfig| | | | | | \--- :app:checkDebugManifest *| | | | | \--- :app:processDebugResources| | | | | +--- :app:mergeDebugResources| | | | | | +--- :app:generateDebugResources| | | | | | | +--- :app:compileDebugRenderscript *| | | | | | | \--- :app:generateDebugResValues| | | | | | \--- :app:prepareDebugDependencies *| | | | | \--- :app:processDebugManifest| | | | | \--- :app:prepareDebugDependencies *| | | | +--- :app:incrementalDebugJavaCompilationSafeguard| | | | +--- :app:javaPreCompileDebug| | | | \--- :app:prepareDebugDependencies *| | | +--- :app:incrementalDebugUnitTestJavaCompilationSafeguard| | | +--- :app:javaPreCompileDebugUnitTest| | | \--- :app:prepareDebugUnitTestDependencies| | | \--- :app:preDebugUnitTestBuild| | | \--- :app:preBuild *| | +--- :app:processDebugJavaRes| | \--- :app:processDebugUnitTestJavaRes| \--- :app:mockableAndroidJar\--- :app:compileDebugUnitTestJavaWithJavac *(*) - subtree omitted (printed previously)
However profiling seems to suggest that each of the prepare*
tasks take around 2ms
each if the dependency is already cached so this should not impact your build too badly (unless you are unable to cache dependencies for some reason than this becomes a bigger problem).
$ ./gradlew --profile --offline testDebug
The biggest offenders here seems to be mergeDebugResources
and processDebugResources
so that may be where you want to focus your efforts.
Hope this helps!