I ran my gradle build profiling with the following command
?./gradlew --profile --offline build
And it showed me the following time spent on tasks.
Task Duration Result
:app 33m25.87s (total)
:app:packageDebug 10m52.81s
:app:processReleaseManifestForPackage 10m52.61s
:app:generateJsonModelRelease 10m39.84s
:app:externalNativeBuildDebug 45.789s
:app:externalNativeBuildRelease 12.549s
:app:mergeDebugNativeLibs 1.350s FROM-CACHE
:app:generateJsonModelDebug 0.373s
...
(many very fast tasks)
OK, so by looking at this, it seems tha app:generateJsonModelRelease
, :app:processReleaseManifestForPackage
and :app:packageDebug
are the biggest offenders. I need help optimizing these tasks.
How can I make them run faster in my project?
My gradle.properties is already as following:
# Project-wide Gradle settings.
# IDE (e.g. Android Studio) users:
# Gradle settings configured through the IDE *will override*
# any settings specified in this file.
# For more details on how to configure your build environment visit
# http://www.gradle.org/docs/current/userguide/build_environment.html
# The Gradle daemon aims to improve the startup and execution time of Gradle.
# When set to true the Gradle daemon is to run the build.
org.gradle.daemon=true
# When set to true, the Android plugin uses the appropriate AndroidX library instead of a Support Library.
android.useAndroidX=true
# Enable Configure on demand
org.gradle.configureondemand=true
# When configured, Gradle will run in incubating parallel mode.
# This option should only be used with decoupled projects. More details, visit
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
org.gradle.parallel=true
# Enable Build Cache
android.enableBuildCache=true
# Enable simple gradle caching
org.gradle.caching=true
# Specifies the JVM arguments used for the daemon process.
# The setting is particularly useful for tweaking memory settings.
# Default value: -Xmx10248m -XX:MaxPermSize=256m
org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8
I have a reasonably fast 16 core PC with Ubuntu 20.04 and expected this project to build a bit faster.
question from:
https://stackoverflow.com/questions/65645520/how-to-speed-up-specific-tasks-on-gradle-build-for-android 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…