Reputation: 2257
This is my top-level "build.gradle" file for my Android Studio (2.1.2) project, which I'm developing on a Mac.
buildscript
{
repositories
{
jcenter()
}
dependencies
{
classpath 'com.android.tools.build:gradle:2.1.2'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects
{
repositories
{
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
Everything works fine until I change that bottom "task clean" block to use the same bracing style, like so.
task clean(type: Delete)
{
delete rootProject.buildDir
}
If I make this change and click on "sync now" in the upper-right corner, I get a syntax error on the left curly-brace line below the word "task".
Error:(28, 0) Cause: startup failed: build file 'build.gradle': 28: Ambiguous expression could be a parameterless closure expression, an isolated open code block, or it may continue a previous statement; solution: Add an explicit parameter list, e.g. {it -> ...}, or force it to be treated as an open block by giving it a label, e.g. L:{...}, and also either remove the previous newline, or add an explicit semicolon ';' @ line 28, column 1. { ^
Is this a bug in Android Studio, Gradle, or...?
Upvotes: 0
Views: 238
Reputation: 2257
As noted in this stack overflow post, the problem is semicolon inference.
Simple gradle build file build error
So the solution in my case is to use this syntax.
task clean(type: Delete) \
{
delete rootProject.buildDir
}
Upvotes: 2