Gradle : Stackoverflow Error

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.

* Where:
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)

* Try:
Run with –stacktrace option to get the stack trace. Run with –info or –debug option to get more log output.

BUILD FAILED

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:-

build_1.gradle

apply from : 'build_2.gradle'

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.

Advertisements

Leave a comment

Filed under Gradle, Open Source

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s