Following the configuration changes per your system RAM to make gradle build faster for the android project.
Step:-1 In gradle.properties turn on below line.
org.gradle.parallel=true
: Excellent for parallel task execution.
Step:-2 gradle=build -x lint -x lintVitalBasicRelease
Good for development builds, excluding time-consuming lint checks. Remember to run these before release!
Step3: This is important one,Increase jvmargs memory
org.gradle.jvmargs=-Xmx8g -XX:MaxMetaspaceSize=512m -Dkotlin.daemon.jvm.options="-Xmx8g" -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8 -XX:+UseParallelGC
:
-Xmx8g
: 8GB heap for Gradle daemon. Suitable for larger projects.-XX:MaxMetaspaceSize=512m
: Metaspace size. Increase if you getOutOfMemoryError: Metaspace
.-Dkotlin.daemon.jvm.options="-Xmx8g"
: Correctly sets Kotlin daemon memory.-XX:+HeapDumpOnOutOfMemoryError
: Helps in debugging memory issues.-Dfile.encoding=UTF-8
: Good for file encoding.-XX:+UseParallelGC
: Enables parallel garbage collection.
android.enableJetifier=false
: Disables Jetifier. This is good if you've migrated fully to AndroidX. If you still have dependencies using the old support library, this needs to be true
(or the line removed, as the default is true).android.nonTransitiveRClass=false
: This can significantly improve build times, but can also cause runtime errors if not handled carefully.android.nonFinalResIds=false
: Prevents non-final resource IDs. Generally, keeping this false
is safer, but there are potential performance gains in specific situations if set to true.