Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
644 views
in Technique[技术] by (71.8m points)

android - Could not find method leftShift() for arguments after updating studio 3.4

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?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...