One of the reasons for Stackoverflow Error is infinite loop. So when Gradle gives ouptput like this:
yogeshwardancharan@yogeshwardancharan-Lenovo-G570:~/android_learning_resources/gradle_resources/ud867/1.01-Exercise-RunYourFirstTask$ gradle tasks
FAILURE: Build failed with an exception.
Script ‘/home/yogeshwardancharan/android_learning_resources/gradle_resources/ud867/1.01-Exercise-RunYourFirstTask/other.gradle’ line: 1
* What went wrong:
A problem occurred evaluating script.
> java.lang.StackOverflowError (no error message)
Run with –stacktrace option to get the stack trace. Run with –info or –debug option to get more log output.
Total time: 1.563 secs
Well , there might be many reasons of the above error , but one of them is creating cyclic dependency in files. To better understand see two build files below:-
apply from : 'build_2.gradle'
apply from : 'build_1.gradle'
So , here , build_1 is trying to import build_2 and vice-versa and since Gradle handles dependency issue during configuration phase by creating a Directed Acyclic Graph , here due to cycle it is not able to do so and gets trapped into infinite loop resulting in Stackoverflow Error.
Stackoverflow Error can also be generated if a file somehow tries to import itself directly or indirectly , because that also results in a cycle.