Hello everyone,

So I've been working on my open source app since last 5 months and everytime i used to start my android studios it used to take around 6 mins to build gradle and the subsequent runs used to take slightly less... and tbh i was frustated of this.

so yeah i decided to dig into whats the issue, googled stuff and found out ./gradlew build --scan which basically generates a detailed HTML dashboard tracking configuration times and task execution timelines

Through that i found out my local machine's 12 core CPU was completely starved coz my peak heap memory usage was sitting at 1.9GB out of 2GB usage hehe :)

so i found out i could increase the memory size and use parallelism and caching
Added this new lines to 'gradle.properties' :

org.gradle.jvmargs=-Xmx6g -XX:+UseParallelGC -Dfile.encoding=UTF-8 org.gradle.parallel=true org.gradle.caching=true 

so basically you could say

12 cores X 6 minutes = 72 minutes of total CPU work
and i was able to save 41 mins cumulative time

so the actual 6 min fell to 26 secs and the subsequent runs took 8 secs only to build gradle....

Ik this might be very basic and ppl here might know bout this but im just an undergrad and though would share my experience here...also if i wrote anything wrong pls correct me 😊

submitted by /u/Boiniok
[link] [comments]