Azure Devops Gradle@3 task stared failing

I’m using gradle@3 task in an azure devops yaml pipeline to bundle an android app.
The pipeline worked with no issues since December 2022.
24th May 2023 the pipeline failed with what I understand is a non specific error message, There have been no changes to the pipeline yaml file or app code since the last successful build.

The debug trace only provides details of java commands from the gradle build processes.

Has anyone else experienced this error and how did you fix it?
Error:

No signature of method: build_6t2iytcirzlbjcsfsvfejohl0.android() is applicable for argument types: (build_6t2iytcirzlbjcsfsvfejohl0$_run_closure1) values: [build_6t2iytcirzlbjcsfsvfejohl0$_run_closure1@f068a61]

Stack trace:

	at org.gradle.launcher.daemon.server.exec.WatchForDisconnection.execute(WatchForDisconnection.java:39)
	at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:104)
	at org.gradle.launcher.daemon.server.exec.ResetDeprecationLogger.execute(ResetDeprecationLogger.java:29)
	at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:104)
	at org.gradle.launcher.daemon.server.exec.RequestStopIfSingleUsedDaemon.execute(RequestStopIfSingleUsedDaemon.java:35)
	at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:104)
	at org.gradle.launcher.daemon.server.exec.ForwardClientInput$2.create(ForwardClientInput.java:78)
	at org.gradle.launcher.daemon.server.exec.ForwardClientInput$2.create(ForwardClientInput.java:75)
	at org.gradle.util.Swapper.swap(Swapper.java:38)
	at org.gradle.launcher.daemon.server.exec.ForwardClientInput.execute(ForwardClientInput.java:75)
	at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:104)
	at org.gradle.launcher.daemon.server.exec.LogAndCheckHealth.execute(LogAndCheckHealth.java:55)
	at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:104)
	at org.gradle.launcher.daemon.server.exec.LogToClient.doBuild(LogToClient.java:63)
	at org.gradle.launcher.daemon.server.exec.BuildCommandOnly.execute(BuildCommandOnly.java:37)
	at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:104)
	at org.gradle.launcher.daemon.server.exec.EstablishBuildEnvironment.doBuild(EstablishBuildEnvironment.java:84)
	at org.gradle.launcher.daemon.server.exec.BuildCommandOnly.execute(BuildCommandOnly.java:37)
	at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:104)
	at org.gradle.launcher.daemon.server.exec.StartBuildOrRespondWithBusy$1.run(StartBuildOrRespondWithBusy.java:52)
	at org.gradle.launcher.daemon.server.DaemonStateCoordinator$1.run(DaemonStateCoordinator.java:297)
	at org.gradle.internal.concurrent.ExecutorPolicy$CatchAndRecordFailures.onExecute(ExecutorPolicy.java:64)
	at org.gradle.internal.concurrent.ManagedExecutorImpl$1.run(ManagedExecutorImpl.java:48)
	at org.gradle.internal.concurrent.ThreadFactoryImpl$ManagedThreadRunnable.run(ThreadFactoryImpl.java:56)
Caused by: groovy.lang.MissingMethodException: No signature of method: build_6t2iytcirzlbjcsfsvfejohl0.android() is applicable for argument types: (build_6t2iytcirzlbjcsfsvfejohl0$_run_closure1) values: [build_6t2iytcirzlbjcsfsvfejohl0$_run_closure1@f068a61]
	at build_6t2iytcirzlbjcsfsvfejohl0.run(D:\a\1\s\apps\colleague-portal-native\android\app\build.gradle:134)
	at org.gradle.groovy.scripts.internal.DefaultScriptRunnerFactory$ScriptRunnerImpl.run(DefaultScriptRunnerFactory.java:91)
	... 153 more

The error means, that something within your android { ... } block is not valid.
It would be very strange if this happened without any change in the build script or dependencies, unless you for example use a dynamic version for the Android Gradle plugin.
Unfortunately the error message with Groovy DSL are often not too helpful and you would need to either see the error or comment out random parts in the android { ... } block to find the actual problem.

This is one of the major points why I strongly recommend using the Kotlin DSL instead.
You immediately get type-safe build scripts, much more helpful error messages if you mess up the syntax and amazingly better IDE support when using a proper IDE like IntelliJ or Android Studio.

Hi Bjorn

I’ve attached the gradle file our build uses, we followed your advice and commented out each section of the android block of the gradle file until we found the point of the build failure.
The version code property on line 154 of the attached file has had a hard coded value of 1 since the pipeline was created and has never caused any issues until now.

We tried changing the versionCode to an incremental value 202306091 and got this error:

No signature of method: build_6t2iytcirzlbjcsfsvfejohl0.android() is applicable for argument types: (build_6t2iytcirzlbjcsfsvfejohl0$_run_closure1) values: [build_6t2iytcirzlbjcsfsvfejohl0$_run_closure1@68a891c8]

Here’s the section of the gradle file where the versionCode is parsed, is it possible that when the build consumes the version code a process runs which fails for a different reason?

versionCode 1
versionName “1.0”

defaultConfig {
applicationId bundleIdentifier
applicationIdSuffix “”
minSdkVersion rootProject.ext.minSdkVersion
targetSdkVersion rootProject.ext.targetSdkVersion

println(“before assigining versionCode Application Version: ${applicationVersion}”)
versionCode 1

println(“after versionCode Application Version: ${applicationVersion}”)
versionName “1.0”
testBuildType System.getProperty(‘testBuildType’, ‘debug’) // This will later be used to control the test apk build type
testInstrumentationRunner ‘androidx.test.runner.AndroidJUnitRunner’
resValue “string”, “app_name”, appDisplayName
resValue “string”, “build_config_package”, bundleIdentifier
resValue “string”, “keystore_signature”, “/${signatureHash}”
}

Anchor Hanover Group Registered Office: Suites A & B, The Heal’s Building, 22-24 Torrington Place, London WC1E 7HJ. A charitable housing association registered as a society under the Co-operative and Community Benefit Societies Act 2014, No. 7843 and registered with the Regulator of Social Housing, No. LH4095. This email and any files transmitted with it are confidential. If you are not the intended recipient of this e-mail please contact the sender immediately, and permanently delete this e-mail. Do not use, disclose, copy, print or rely on the information contained in this e-mail or any attachment in any manner. The statements and opinions expressed in this message are those of the author and do not necessarily reflect those of Anchor Hanover Group. Anchor Hanover Group does not accept any responsibility for the author’s views. Reasonable care has been taken to ensure this communication does not contain computer viruses, but no responsibility is accepted, and recipients are advised to undertake their own checks.

(Attachment build (1).gradle is missing)

I’ve attached the gradle file our build uses

E-Mail attachments do not get attached to the forum.
But anyway at least I cannot tell you, I’m not into Android development, so cannot say much about AGP specifics.

is it possible that when the build consumes the version code a process runs which fails for a different reason?

Unlikely, the error means that the syntax you use is wrong, e. g. by calling a method that does not exist or similar.
Maybe the documentation of the AGP can help you.

PS: It is Björn or Bjoern, but not Bjorn. :wink: