quezak
quezak

Reputation: 1378

StackOverflowError: null in Android Studio on Project Structure

Ever since I updated to Android Studio 2.3, there is an IDE error in some cases: for example when I click File->Project Structure, try to open any layout XML, or even click any point in the code of any build.gradle file (these at least open without exceptions). The error says StackOverflowError: null, and the stack trace is the same in all cases:

null
java.lang.StackOverflowError
    at java.util.regex.Pattern.sequence(Pattern.java:2079)
    at java.util.regex.Pattern.expr(Pattern.java:1996)
    at java.util.regex.Pattern.compile(Pattern.java:1696)
    at java.util.regex.Pattern.<init>(Pattern.java:1351)
    at java.util.regex.Pattern.compile(Pattern.java:1028)
    at java.lang.String.replaceAll(String.java:2223)
    at com.android.tools.idea.gradle.dsl.parser.settings.ProjectPropertiesDslElement.getStandardProjectKey(ProjectPropertiesDslElement.java:52)
    at com.android.tools.idea.gradle.dsl.parser.elements.GradleDslExpression.resolveProjectReference(GradleDslExpression.java:191)
    at com.android.tools.idea.gradle.dsl.parser.elements.GradleDslExpression.resolveReference(GradleDslExpression.java:92)
    at com.android.tools.idea.gradle.dsl.parser.elements.GradleDslReference.getValue(GradleDslReference.java:66)
    at com.android.tools.idea.gradle.dsl.parser.elements.GradleDslExpression.resolveReference(GradleDslExpression.java:152)
    at com.android.tools.idea.gradle.dsl.parser.elements.GradleDslReference.getValue(GradleDslReference.java:66)
    at com.android.tools.idea.gradle.dsl.parser.elements.GradleDslExpression.resolveReference(GradleDslExpression.java:152)

... and the last 2 lines repeat forever.

What can I do to find the source of this problem?

It looks like there's a circular reference somewhere in my build configs, or the internals of Studio? But I can't find any by hand. It would be helpful if I at least knew what's the pattern or the reference mentioned in the stack trace.

Things I already tried:

I'm using Android Studio 2.3.3 with all the plugins and android libs updated, gradle 3.3 and gradle plugin 2.3.1; all that on an up-to-date gentoo linux.

Upvotes: 3

Views: 782

Answers (1)

quezak
quezak

Reputation: 1378

I've resolved the issue. There were these 3 lines in my main build.gradle:

ext.kotlinVersion = kotlinVersion
ext.supportLibVersion = supportLibVersion
ext.playServicesVersion = playServicesVersion

In this project the *Version variables are assigned in gradle.properties file, not in build.gradle files, so they're already accessible in all module gradle files, and the lines above create a circular reference. (I'm no expert on gradle, that's just a guess)

I think they were added by the Kotlin plugin at some point (the "configure Kotlin in project" option), and the automated edit messed up our complicated configs. Or some previous dev left it there. I can't seem to reproduce it on a clean project.

Upvotes: 1

Related Questions