Skip to content
Advertisement

Gradle 7 StackOverflowError when building

I’ve got a large Gradle project that I’m attempting to upgrade from Gradle 6 to Gradle 7.4.2. After the upgrade, I see inconsistent StackOverflowErrors when running gradle build – sometimes the command is successful and sometimes it’s not.

Error:

JavaScript

Stack trace:

JavaScript

build.gradle file:

JavaScript

gradle.properties file:

JavaScript

Does anyone have any tips or recommendations for working out what might be causing this problem?

Advertisement

Answer

I’ve solved this by adding the JVM arguments -XX:ThreadStackSize=4096 -XX:CompilerThreadStackSize=4096 to my gradle.properties file:

JavaScript

Running java -XX:+PrintFlagsFinal -version | grep ThreadStackSize on my machine gave me the default values (1024) for each of these settings, and upping them has sorted out my problem.

User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement