3

on gradle 2.1.3 I could do:

assembleRelease
{
    doFirst()
    {
    //some code
    }
}

But when I updated to gradle 2.2.0 I get an error:

Error:(12, 1) A problem occurred evaluating project ':MyProj'.
> Could not find method assembleRelease() for arguments [build_6dlppzyvvovwra7h55acb4kp$_run_closure1@543a3981] on project ':MyProj' of type org.gradle.api.Project.

Can you please help me with that?

Dim
  • 4,527
  • 15
  • 80
  • 139

1 Answers1

4

It seems to be a common issue for version update to 2.2.0. You can find some similar questions on SO, for example here. But they all lead to a common workaround - rewrite your task this way:

tasks.whenTaskAdded { task ->
    if (task.name == 'assembleRelease') {
        task.doFirst {
            //some code
        }
    }
}

Not sure, but it seems, that assembleRelease is not available at the moment you try to point it in your script since 2.2.0 version.

Community
  • 1
  • 1
Stanislav
  • 27,441
  • 9
  • 87
  • 82