.NET MAUI › Troubleshooting & Common Errors
How do you fix 'Java heap space'/build OutOfMemory errors on Android?
IntermediateAnswer
Increase the Java max heap for the Android build (JavaMaximumHeapSize), enable D8/R8 and resource shrinking, disable multidex issues, and ensure you're not bundling excessive assets. For large apps, enable AndroidLinkMode and reduce ABIs during debug to speed and lighten builds.
<PropertyGroup>
<JavaMaximumHeapSize>2G</JavaMaximumHeapSize>
<AndroidEnableMultiDex>true</AndroidEnableMultiDex>
</PropertyGroup>Real-world example A CI Android build stops failing after raising the Java heap size and enabling R8 shrinking.