Gradle: "A problem occurred evaluating settings" When Having a Large Number of Modules

Mar 16, 2021

Gradle may throw a weird exception when having a large number of modules:

org.gradle.api.GradleScriptException: A problem occurred evaluating settings 'myproject'.
        …
Caused by: java.lang.NoSuchMethodError: 'java.lang.Object[] org.codehaus.groovy.runtime.ArrayUtil.createArray(java.lang.Object, java.lang.Object, java.lang.Object, java.lang.Object, java.lang.Object, java.lang.Object, java.lang.Object, java.lang.Object, java.lang.Object, java.lang.Object, java.lang.Object, java.lang.Object, java.lang.Object, java.lang.Object, java.lang.Object, java.lang.Object, java.lang.Object, java.lang.Object, java.lang.Object, java.lang.Object, java.lang.Object, java.lang.Object, java.lang.Object, java.lang.Object, java.lang.Object, java.lang.Object, java.lang.Object, java.lang.Object, java.lang.Object, java.lang.Object, java.lang.Object, java.lang.Object, java.lang.Object, java.lang.Object, java.lang.Object, java.lang.Object, java.lang.Object, java.lang.Object, java.lang.Object, java.lang.Object, java.lang.Object, java.lang.Object, java.lang.Object, java.lang.Object, java.lang.Object, java.lang.Object, java.lang.Object, java.lang.Object, java.lang.Object, java.lang.Object, java.lang.Object, java.lang.Object, java.lang.Object, java.lang.Object, java.lang.Object, java.lang.Object, java.lang.Object, java.lang.Object, java.lang.Object, java.lang.Object, java.lang.Object, java.lang.Object, java.lang.Object, java.lang.Object, java.lang.Object, java.lang.Object,…)'

The long parameter list is already very suspicious. After searching about this issue, it turns out that a large number of modules (~250) in settings.properties can be the cause of this problem. As it turns out include internally makes use of ArrayUtil.createArray(…), which has a limited amount of parameters.

Problematic settings.properties when having a lot of modules:

include ':app',
    ':module1',
    ':module2',
    ':module3',
    ':module4',
    ':module5',
    

Luckily, it’s easy to work around that issue by limiting the number of modules per include statement, for example:

include ':app'
include ':module1'
include ':module2'
include ':module3'
include ':module4'
include ':module5'

You might also like