After updating studio 3.4
and Gradle version to 5.1.1
I got the error on my task as Could not find method leftShift()
My task:
task incrementBetaVersion << {
println("Incrementing Beta Version Number...")
incrementVersionNumber('BetaVersionNumber')
println("Incrementing Beta Version Number...")
incrementVersionName('BetaVersionName')
}
I got the error for the left shift operator <<
in the line.
How to resolve this error?
To solve this error, change <<
with doLast
like this.
task incrementBetaVersion {
doLast {
println("Incrementing Beta Version Number...")
incrementVersionNumber('BetaVersionNumber')
println("Incrementing Beta Version Number...")
incrementVersionName('BetaVersionName')
}
}
Left shift operator represent's doLast { }
.
<<
was deprecated in Gradle 4.x and removed in Gradle 5.0
From Docs:
<<
for task definitions no longer works. In other words, you can not use the syntax
task myTask << { … }
.
Use the Task.doLast()
method instead, like this:
task myTask {
doLast {
...
...
}
}
More info here: https://discuss.gradle.org/t/could-not-find-method-leftshift-for-arguments-on-task-of-type-org-gradle-api-defaulttask/30614
https://docs.gradle.org/current/userguide/upgrading_version_4.html#changes_5.0