Flutter. build error creating TaskExecuter

Gradle could not start your build.

Cannot create service of type TaskExecuter using method ProjectExecutionServices.createTaskExecuter() as there is a problem with parameter #9 of type ReservedFileSystemLocationRegistry.
Cannot create service of type ReservedFileSystemLocationRegistry using method ProjectExecutionServices.createReservedFileLocationRegistry() as there is a problem with parameter #1 of type List.
Could not create service of type ExecutionHistoryStore using ExecutionBuildServices.createExecutionHistoryStore().
Cannot lock execution history cache (/home/user/myapp/android/.gradle/8.12/executionHistory) as it has already been locked by this process.