Found the solution
just now tested, that “Evaluate Expression” works (with groovy as lang for *.gradle scripts) if we add a project/module level dependency on groovy lib. (can be compileOnly or runtimeOnly, or its supersets, cannot be on annotationProcessor or its supersets though)
NOTE: However the appropriate (compile/runtime)classpath will be polluted with this groovy lib even though if it is undesired. So it is preferred to use it in compileOnly configuration.
Tested to be working on both IDEA and AndroidStudio (ie, gradle and android-gradle-plugin).
NOTE: adding groovy to buildscript dependencies via classpath doesn’t help/work.
IDEA:
Android-Studio: