Android build performance
Create Local gradle.properties
override to the project root gradle.properties
which is used for CI
Introduction
We use the project root gradle.properties to configure the CI environment.
These are likely sub-optimal for Engineers Local machines.
Steps to Create Local gradle.properties
Create gradle.properties in your ~/.gradle/ directory i.e ~/.gradle/gradle.properties
- Open Android Studio;
- Open the android-rebuild project in Android Studio;
- Navigate to the project root gradle.properties :
- Cmd + Shift + o → Search gradle.properties → Click on the first one that pops up. It should say gradle.properties .;
- Copy the contents of the project root gradle.properties :
- Click into the file;
- Select the whole contents of the file:
- Cmd + a;
- Copy the selected contents:
- Cmd + c;
- Open Terminal in Android Studio OR a stand-alone Terminal:
- Click the Terminal button; OR
- Open Spotlight Search:
- Cmd + Spacebar;
- Search for Terminal;
- Navigate to the Gradle Directory in your GRADLE_USER_HOME which should be the user home e.g. ~/.gradle/ :
- cd ~/.gradle/;
- Open the directory in Visual Studio Code or SKIP if using Vim:
- code .;
- Create a new file called gradle.properties:
- Visual Studio Code: Create New File... gradle.properties;
- Vim: vim gradle.properties;
Update / Modify the gradle.properties
- Open gradle.properties;
- Paste the contents of root project gradle.properties (It's on your clipboard) into the new gradle.properties :
- Click into the gradle.properties;
- Paste your clipboard: Cmd + v;
Update the Gradle JVM Arguments
- Update the line with org.gradle.jvmargs so that the following parameters have the following values:
- Minimum Java Heap Size: -Xms8g or -Xms10g;
- Maximum Java Heap Size: The same as the Minimum Java Heap Size i.e -Xmx8g or -Xmx10g;
- Max Metaspace Size: -XX:MaxMetaspaceSize=1g;
Update the Gradle Parallel Task Execution
- Enable Parallel Task Execution: org.gradle.parallel = true;
- Set Max Parallel Workers:
- org.gradle.workers.max = 8 ;
- 8 could be Maximum number of CPUs - 1;
Update the Kotlin Daemon JVM Arguments
- Update the line with kotlin.daemon.jvmargs so that the following parameters have the following values:
- Minimum Java Heap Size: -Xms1g ;
- Maximum Java Heap Size: The same as the Minimum Java Heap Size i.e -Xmx1g;
- Max Metaspace Size: -XX:MaxMetaspaceSize=512m;
- Save & Close the file;
- Gradle Sync in Android Studio;