In the "old days", the build tool knew when it had and didn't have to rebuild an application by looking at the time stamps of the individual source files. Why does Gradle, the most modern tool for building Android application, use 17 seconds in my case to do god knows what, before deplyoing and launching an app that is not changed since last build?
The first 8 seconds seems to be spent on building the build script ("Configuring")
The next 9 seconds is spent on running the following task:
:app:preBuild
:app:preDebugBuild
:app:checkDebugManifest
:app:preReleaseBuild
:library:compileLint
:library:copyReleaseLint UP-TO-DATE
:library:mergeReleaseProguardFiles UP-TO-DATE
:library:preBuild
:library:preReleaseBuild
:library:checkReleaseManifest
:library:preDebugBuild
:library:preDebugTestBuild
:library:prepareComAndroidSupportAppcompatV71910Library UP-TO-DATE
:library:prepareComGoogleAndroidGmsPlayServices3265Library UP-TO-DATE
:library:prepareReleaseDependencies
:library:compileReleaseAidl UP-TO-DATE
:library:compileReleaseRenderscript UP-TO-DATE
:library:generateReleaseBuildConfig UP-TO-DATE
:library:generateReleaseAssets UP-TO-DATE
:library:mergeReleaseAssets
:library:processReleaseManifest UP-TO-DATE
:library:crashlyticsCleanupResourcesRelease
:library:crashlyticsUploadStoredDeobsRelease
:library:crashlyticsGenerateResourcesRelease
:library:generateReleaseResValues UP-TO-DATE
:library:generateReleaseResources UP-TO-DATE
:library:mergeReleaseResources
:library:processReleaseResources
:library:generateReleaseSources
:library:compileReleaseJava UP-TO-DATE
:library:processReleaseJavaRes UP-TO-DATE
:library:packageReleaseJar UP-TO-DATE
:library:compileReleaseNdk UP-TO-DATE
:library:packageReleaseJniLibs UP-TO-DATE
:library:packageReleaseLocalJar UP-TO-DATE
:library:packageReleaseRenderscript UP-TO-DATE
:library:packageReleaseResources
:library:bundleRelease
:app:prepareComAndroidSupportAppcompatV71910Library UP-TO-DATE
:app:prepareComGoogleAndroidGmsPlayServices5089Library UP-TO-DATE
:app:prepareComMixpanelAndroidMixpanelAndroid431Library UP-TO-DATE
:app:prepareVGSwipelibraryUnspecifiedLibrary
:app:prepareDebugDependencies
:app:compileDebugAidl UP-TO-DATE
:app:compileDebugRenderscript UP-TO-DATE
:app:generateDebugBuildConfig UP-TO-DATE
:app:generateDebugAssets UP-TO-DATE
:app:mergeDebugAssets
:app:processDebugManifest UP-TO-DATE
:app:crashlyticsCleanupResourcesDebug
:app:crashlyticsUploadStoredDeobsDebug
:app:crashlyticsGenerateResourcesDebug
:app:generateDebugResValues UP-TO-DATE
:app:generateDebugResources UP-TO-DATE
:app:mergeDebugResources
:app:processDebugResources
:app:generateDebugSources
:app:compileDebugJava UP-TO-DATE
:app:preDexDebug UP-TO-DATE
:app:dexDebug UP-TO-DATE
:app:crashlyticsStoreDeobsDebug
:app:crashlyticsUploadDeobsDebug
:app:crashlyticsCleanupResourcesAfterUploadDebug
:app:compileDebugNdk UP-TO-DATE
:app:processDebugJavaRes UP-TO-DATE
:app:validateDebugSigning
:app:packageDebug
:app:zipalignDebug
:app:assembleDebug
:library:copyDebugLint UP-TO-DATE
:library:mergeDebugProguardFiles UP-TO-DATE
:library:checkDebugManifest
:library:prepareDebugDependencies
:library:compileDebugAidl UP-TO-DATE
:library:compileDebugRenderscript UP-TO-DATE
:library:generateDebugBuildConfig UP-TO-DATE
:library:generateDebugAssets UP-TO-DATE
:library:mergeDebugAssets
:library:processDebugManifest UP-TO-DATE
:library:crashlyticsCleanupResourcesDebug
:library:crashlyticsUploadStoredDeobsDebug
:library:crashlyticsGenerateResourcesDebug
:library:generateDebugResValues UP-TO-DATE
:library:generateDebugResources UP-TO-DATE
:library:mergeDebugResources
:library:processDebugResources
:library:generateDebugSources
:library:compileDebugJava UP-TO-DATE
:library:processDebugJavaRes UP-TO-DATE
:library:packageDebugJar UP-TO-DATE
:library:compileDebugNdk UP-TO-DATE
:library:packageDebugJniLibs UP-TO-DATE
:library:packageDebugLocalJar UP-TO-DATE
:library:packageDebugRenderscript UP-TO-DATE
:library:packageDebugResources
:library:bundleDebug
:library:crashlyticsStoreDeobsDebug
:library:crashlyticsUploadDeobsDebug
:library:crashlyticsCleanupResourcesAfterUploadDebug
:library:assembleDebug
What happened? Why does I as a developer need to spend 17 seconds waiting for the build system to determine that nothing has changed?
Is there hacks to work around this shortcoming, so that when I simply want to relaunch my app from Android Studio I don't need to wait for it to recompile?
I know I can create a Run configuration where I remove the "Make" step, but then the process of determining whether anything is changed or not, is left up to me as a developer to decide. I don't think that's an acceptable solution.
Use gradle daemon, configure it using gradle.properties.
The Gradle daemon (sometimes referred as the build daemon) aims to improve the startup and execution time of Gradle
Gradle is java based tool. Most of the time is spent starting JVM. Your 8 and 9 seconds are due to Java Compiling and JVM starting. Gradle daemon will offset these issues.
TL;DR; Gradle daemon will make your builds a lot faster.
Add gradle.properties file to same folder as your build.gradle. Add following property this file.
org.gradle.daemon=true
See two runs of gradle
P:\github\WekaExamples>gradle
:help
Welcome to Gradle 2.2.
To run a build, run gradle <task> ...
To see a list of available tasks, run gradle tasks
To see a list of command-line options, run gradle --help
BUILD SUCCESSFUL
Total time: 14.545 secs
P:\github\WekaExamples>gradle
:help
Welcome to Gradle 2.2.
To run a build, run gradle <task> ...
To see a list of available tasks, run gradle tasks
To see a list of command-line options, run gradle --help
BUILD SUCCESSFUL
Total time: 3.578 secs
Second one is a lot faster due to gradle daemon.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With