java.lang.OutOfMemoryError: GC overhead limit exceeded when dexing
This is relevant if your builds are crashing due to something like:
Exception in thread
"pool-1-thread-2"
Exception in thread
"pool-1-thread-3"
Exception in thread
"pool-1-thread-4"
java.lang.OutOfMemoryError: GC overhead limit exceeded
This is happening because your project has tons of classes to churn through and the dexing process is using too much memory. Run your gradle build with “–info –debug” and you’ll see it failing while dexing a bunch of imports.
Step-by-step Guide
- Open your app’s
build.gradle
(not the one in the project root) and add:android {
//snip
//add this into your existing 'android' block
dexOptions {
javaMaxHeapSize
"4g"
}
//snip
}
- Try your build again. Experiment with the value as needed.