Currently we prepare the migration to Gradle 9. Our whole Android project build and pipeline is working so far. But we get the following error when running sonar Gradle task:
[2025-07-03T14:42:18.387Z] > Task :sonar FAILED
[2025-07-03T14:42:18.387Z]
[2025-07-03T14:42:18.387Z] FAILURE: Build failed with an exception.
[2025-07-03T14:42:18.387Z]
[2025-07-03T14:42:18.387Z] * What went wrong:
[2025-07-03T14:42:18.387Z] Execution failed for task ':sonar'.
[2025-07-03T14:42:18.387Z] > Resolution of the configuration ':app:debugCompileClasspath' was attempted without an exclusive lock. This is unsafe and not allowed.
[2025-07-03T14:42:18.387Z]
[2025-07-03T14:42:18.387Z] * Try:
[2025-07-03T14:42:18.387Z] > For more information, please refer to https://docs.gradle.org/9.0.0-rc-1/userguide/viewing_debugging_dependencies.html.html#sub:resolving-unsafe-configuration-resolution-errors in the Gradle documentation.
[2025-07-03T14:42:18.387Z] > Run with --stacktrace option to get the stack trace.
[2025-07-03T14:42:18.387Z] > Run with --info or --debug option to get more log output.
[2025-07-03T14:42:18.387Z] > Run with --scan to generate a Build Scan (Powered by Develocity).
[2025-07-03T14:42:18.387Z] > Get more help at https://help.gradle.org.
[2025-07-03T14:42:18.387Z]
[2025-07-03T14:42:18.387Z] BUILD FAILED in 5s
We are using sonar plugin version 6.2.0.5505.
With Gradle 8.14.2 everthing is working.
Would be nice if you could verify that and make sure we are not blocked when Gradle 9 hits final.
thanks for your reply. We have a dedicated step in our pipeline which simply executes:
sh â./gradlew sonarâ
In general we use Sonarqube in an mixed Android and Kotlin-only multimodule project. There is no special configuration or logic involved.
The tasks succeeds with latest stable Gradle 8.14.3.
I can try to provide a reproducable project. But I thought you might have some test projects where you can check Gradle 9.0.0-rc-1 aswell and see if you run into the same issue.
Still the sonar tasks only succeeds when adding ââno-parallelâ. New error message without this is:
> Task :sonar FAILED
1 problem was found storing the configuration cache.
- Task `:sonar` of type `org.sonarqube.gradle.SonarTask`: error writing value of type 'org.gradle.api.internal.provider.DefaultMapProperty'
Edit: Nevermind, rerun the pipeline with --stacktrace flag and still get the same error message as 9.0.0-rc-1:
[2025-07-18T09:09:40.263Z] org.gradle.api.tasks.TaskExecutionException: Execution failed for task â:sonarâ.
[2025-07-18T09:09:40.263Z] at org.gradle.api.internal.tasks.execution.CatchExceptionTaskExecuter.execute(CatchExceptionTaskExecuter.java:38)
[2025-07-18T09:09:40.263Z] at org.gradle.api.internal.tasks.execution.EventFiringTaskExecuter$1.executeTask(EventFiringTaskExecuter.java:77)
[2025-07-18T09:09:40.264Z] at org.gradle.api.internal.tasks.execution.EventFiringTaskExecuter$1.call(EventFiringTaskExecuter.java:55)
[2025-07-18T09:09:40.264Z] at org.gradle.api.internal.tasks.execution.EventFiringTaskExecuter$1.call(EventFiringTaskExecuter.java:52)
[2025-07-18T09:09:40.264Z] at org.gradle.internal.operations.DefaultBuildOperationRunner$CallableBuildOperationWorker.execute(DefaultBuildOperationRunner.java:209)
[2025-07-18T09:09:40.264Z] at org.gradle.internal.operations.DefaultBuildOperationRunner$CallableBuildOperationWorker.execute(DefaultBuildOperationRunner.java:204)
[2025-07-18T09:09:40.264Z] at org.gradle.internal.operations.DefaultBuildOperationRunner$2.execute(DefaultBuildOperationRunner.java:66)
[2025-07-18T09:09:40.264Z] at org.gradle.internal.operations.DefaultBuildOperationRunner$2.execute(DefaultBuildOperationRunner.java:59)
[2025-07-18T09:09:40.264Z] at org.gradle.internal.operations.DefaultBuildOperationRunner.execute(DefaultBuildOperationRunner.java:166)
[2025-07-18T09:09:40.264Z] at org.gradle.internal.operations.DefaultBuildOperationRunner.execute(DefaultBuildOperationRunner.java:59)
[2025-07-18T09:09:40.264Z] at org.gradle.internal.operations.DefaultBuildOperationRunner.call(DefaultBuildOperationRunner.java:53)
[2025-07-18T09:09:40.264Z] at org.gradle.api.internal.tasks.execution.EventFiringTaskExecuter.execute(EventFiringTaskExecuter.java:52)
[2025-07-18T09:09:40.264Z] at org.gradle.execution.plan.LocalTaskNodeExecutor.execute(LocalTaskNodeExecutor.java:45)
[2025-07-18T09:09:40.264Z] at org.gradle.execution.taskgraph.DefaultTaskExecutionGraph$InvokeNodeExecutorsAction.execute(DefaultTaskExecutionGraph.java:347)
[2025-07-18T09:09:40.265Z] at org.gradle.execution.taskgraph.DefaultTaskExecutionGraph$InvokeNodeExecutorsAction.execute(DefaultTaskExecutionGraph.java:334)
[2025-07-18T09:09:40.265Z] at org.gradle.execution.taskgraph.DefaultTaskExecutionGraph$BuildOperationAwareExecutionAction.lambda$execute$0(DefaultTaskExecutionGraph.java:330)
[2025-07-18T09:09:40.265Z] at org.gradle.internal.operations.CurrentBuildOperationRef.with(CurrentBuildOperationRef.java:84)
[2025-07-18T09:09:40.265Z] at org.gradle.execution.taskgraph.DefaultTaskExecutionGraph$BuildOperationAwareExecutionAction.execute(DefaultTaskExecutionGraph.java:330)
[2025-07-18T09:09:40.265Z] at org.gradle.execution.taskgraph.DefaultTaskExecutionGraph$BuildOperationAwareExecutionAction.execute(DefaultTaskExecutionGraph.java:319)
[2025-07-18T09:09:40.265Z] at org.gradle.execution.plan.DefaultPlanExecutor$ExecutorWorker.execute(DefaultPlanExecutor.java:459)
[2025-07-18T09:09:40.265Z] at org.gradle.execution.plan.DefaultPlanExecutor$ExecutorWorker.run(DefaultPlanExecutor.java:376)
[2025-07-18T09:09:40.265Z] at org.gradle.internal.concurrent.ExecutorPolicy$CatchAndRecordFailures.onExecute(ExecutorPolicy.java:64)
[2025-07-18T09:09:40.265Z] at org.gradle.internal.concurrent.AbstractManagedExecutor$1.run(AbstractManagedExecutor.java:47)
[2025-07-18T09:09:40.265Z] Caused by: org.gradle.api.internal.artifacts.configurations.DefaultConfiguration$IllegalResolutionException: Resolution of the configuration â:app:googleDevDebugCompileClasspathâ was attempted without an exclusive lock. This is unsafe and not allowed.
No, adding this config to your gradle.properties will disable configuration cache and parallel execution of Gradle for the whole project. I would not recommend this, since you will see a huge decreased in performance for most projects.
Also we use configuration cache for 2+ years without any issues. Why should you also disable this?
Workaround should be just executing the sonar task like this (as pointed out in #6): ./gradlew sonar --no-parallel
Iâm just providing details about the steps I took to get it working on my setup. This information might help others keep using the sonar task in the meantime, until we can explore solutions for improved compatibility.
As you said, adding -no-parallel doesnât solve the entire issue.
I think there is some confusing and/or misunderstanding.
Still I would not recommend people to modify their Gradle project configuration, when the only issue is about the single sonar task. Also the statement about this approach being âequivalentâ is not true from my perspective.
Sorry, maybe I didnât make it clear enough, but the error message in the quote only occurs without adding âno-parallel.
So the initial workaround by just adding no-parallel at task level should be enough and was actually provided by a Gradle employee for an different plugin that faced this issue.
Resolution of the configuration â:SomeSubProject:compileClasspathâ was attempted without an exclusive lock. This is unsafe and not allowed.
For more information, please refer to https://docs.gradle.org/9.0.0/userguide/viewing_debugging_dependencies.html#sub:resolving-unsafe-configuration-resolution-errors in the Gradle documentation.
Adding â-no-parallel is only a viable workaround if youâre only running a single task. Personally, Iâm running jacocoTestReport testCodeCoverageReport sonar and these tasks result in compiling the project and running all tests, so thats a few hundred tasks.
Have you created a bug ticket for fixing this now that Gradle 9 is fully released? That way I have something I can keep track of to know when it is safe to upgrade my gradle version.
If there is anything I can do to help (such as providing a reproducer project), let me know.
My understanding (as of this morning) is that weâll look at better Gradle 9 support in the teamâs next iteration. I donât have a ticket to share yet.
@lbenedetto You do not need to execute these Gradle tasks in a single line, since they will be executed sequentially anyways (as far as I understand Gradle parallel execution only runs independent tasks from different modules in parallel). You should be able to just run: