Android Studio: Gradle project sync failed

I am making a new project in Android Studio, but I have a problem when it is syncing gradle for the first time and I can’t do anymore.
I get these error messages:

FAILURE: Build failed with an exception.

* What went wrong:
java.io.UncheckedIOException: Could not move temporary workspace (C:\Users\ACER\AndroidStudioProjects\CamaraX\.gradle\8.6\dependencies-accessors\dcbcd87108cec70bb467e05d5172bee8efb944af-cabbf297-8dbc-470e-8173-601d61c619c7) to immutable location (C:\Users\ACER\AndroidStudioProjects\CamaraX\.gradle\8.6\dependencies-accessors\dcbcd87108cec70bb467e05d5172bee8efb944af)
> Could not move temporary workspace (C:\Users\ACER\AndroidStudioProjects\CamaraX\.gradle\8.6\dependencies-accessors\dcbcd87108cec70bb467e05d5172bee8efb944af-cabbf297-8dbc-470e-8173-601d61c619c7) to immutable location (C:\Users\ACER\AndroidStudioProjects\CamaraX\.gradle\8.6\dependencies-accessors\dcbcd87108cec70bb467e05d5172bee8efb944af)
...
* Exception is:
java.lang.RuntimeException: java.io.UncheckedIOException: Could not move temporary workspace (C:\Users\ACER\AndroidStudioProjects\CamaraX\.gradle\8.6\dependencies-accessors\dcbcd87108cec70bb467e05d5172bee8efb944af-cabbf297-8dbc-470e-8173-601d61c619c7) to immutable location (C:\Users\ACER\AndroidStudioProjects\CamaraX\.gradle\8.6\dependencies-accessors\dcbcd87108cec70bb467e05d5172bee8efb944af)
...
Caused by: java.io.UncheckedIOException: Could not move temporary workspace (C:\Users\ACER\AndroidStudioProjects\CamaraX\.gradle\8.6\dependencies-accessors\dcbcd87108cec70bb467e05d5172bee8efb944af-cabbf297-8dbc-470e-8173-601d61c619c7) to immutable location (C:\Users\ACER\AndroidStudioProjects\CamaraX\.gradle\8.6\dependencies-accessors\dcbcd87108cec70bb467e05d5172bee8efb944af)
	at org.gradle.internal.execution.steps.AssignImmutableWorkspaceStep$WorkspaceMoveHandler.unableToMoveBecause(AssignImmutableWorkspaceStep.java:258)
	at org.gradle.internal.execution.steps.AssignImmutableWorkspaceStep$WorkspaceMoveHandler.lambda$executeMoveOrThrow$0(AssignImmutableWorkspaceStep.java:228)
	at org.gradle.internal.execution.steps.AssignImmutableWorkspaceStep$WorkspaceMoveHandler.executeMoveOr(AssignImmutableWorkspaceStep.java:219)
	at org.gradle.internal.execution.steps.AssignImmutableWorkspaceStep$WorkspaceMoveHandler.executeMoveOrThrow(AssignImmutableWorkspaceStep.java:227)
	at org.gradle.internal.execution.steps.AssignImmutableWorkspaceStep.lambda$moveTemporaryWorkspaceToImmutableLocation$4(AssignImmutableWorkspaceStep.java:184)
	at org.gradle.internal.execution.workspace.impl.CacheBasedImmutableWorkspaceProvider$1.withTemporaryWorkspace(CacheBasedImmutableWorkspaceProvider.java:121)
	at org.gradle.internal.execution.steps.AssignImmutableWorkspaceStep.lambda$moveTemporaryWorkspaceToImmutableLocation$5(AssignImmutableWorkspaceStep.java:181)
	at org.gradle.internal.execution.steps.AssignImmutableWorkspaceStep$WorkspaceMoveHandler.executeMoveOr(AssignImmutableWorkspaceStep.java:219)
	at org.gradle.internal.execution.steps.AssignImmutableWorkspaceStep.moveTemporaryWorkspaceToImmutableLocation(AssignImmutableWorkspaceStep.java:175)
	at org.gradle.internal.execution.steps.AssignImmutableWorkspaceStep.lambda$executeInTemporaryWorkspace$1(AssignImmutableWorkspaceStep.java:154)
	at org.gradle.internal.execution.workspace.impl.CacheBasedImmutableWorkspaceProvider$1.withTemporaryWorkspace(CacheBasedImmutableWorkspaceProvider.java:121)
	at org.gradle.internal.execution.steps.AssignImmutableWorkspaceStep.executeInTemporaryWorkspace(AssignImmutableWorkspaceStep.java:133)
	at org.gradle.internal.execution.steps.AssignImmutableWorkspaceStep.lambda$execute$0(AssignImmutableWorkspaceStep.java:88)
	at org.gradle.internal.execution.steps.AssignImmutableWorkspaceStep.execute(AssignImmutableWorkspaceStep.java:88)
	at org.gradle.internal.execution.steps.AssignImmutableWorkspaceStep.execute(AssignImmutableWorkspaceStep.java:57)
	at org.gradle.internal.execution.steps.IdentityCacheStep.execute(IdentityCacheStep.java:36)
	at org.gradle.internal.execution.steps.IdentityCacheStep.execute(IdentityCacheStep.java:26)
	at org.gradle.internal.execution.steps.IdentifyStep.execute(IdentifyStep.java:47)
	at org.gradle.internal.execution.steps.IdentifyStep.execute(IdentifyStep.java:34)
	at org.gradle.internal.execution.impl.DefaultExecutionEngine$1.execute(DefaultExecutionEngine.java:61)
	at org.gradle.api.internal.catalog.DefaultDependenciesAccessors.executeWork(DefaultDependenciesAccessors.java:190)
	at org.gradle.api.internal.catalog.DefaultDependenciesAccessors.writeDependenciesAccessors(DefaultDependenciesAccessors.java:167)
	at org.gradle.api.internal.catalog.DefaultDependenciesAccessors.generateAccessors(DefaultDependenciesAccessors.java:153)
	... 130 more
Caused by: java.nio.file.AccessDeniedException: C:\Users\ACER\AndroidStudioProjects\CamaraX\.gradle\8.6\dependencies-accessors\dcbcd87108cec70bb467e05d5172bee8efb944af-cabbf297-8dbc-470e-8173-601d61c619c7 -> C:\Users\ACER\AndroidStudioProjects\CamaraX\.gradle\8.6\dependencies-accessors\dcbcd87108cec70bb467e05d5172bee8efb944af
	at org.gradle.internal.vfs.impl.DefaultFileSystemAccess.lambda$moveAtomically$12(DefaultFileSystemAccess.java:224)
	at org.gradle.internal.vfs.impl.DefaultFileSystemAccess.write(DefaultFileSystemAccess.java:212)
	at org.gradle.internal.vfs.impl.DefaultFileSystemAccess.moveAtomically(DefaultFileSystemAccess.java:223)
	at org.gradle.internal.execution.steps.AssignImmutableWorkspaceStep$WorkspaceMoveHandler.executeMoveOr(AssignImmutableWorkspaceStep.java:208)
	... 150 more

This is my gradle-wrapper.properties:

#Thu May 16 12:13:00 GMT-06:00 2024
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.6-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists

I tried switching to a newer version but the same thing happens and with older versions I get this:

Minimum supported Gradle version is 8.6. Current version is 8.5.

Please fix the project's Gradle settings.
Change Gradle version in Gradle wrapper to 8.6 and re-import project
Open Gradle wrapper properties
Gradle Settings.

According to "Immutable workspace contents have been modified" failure when workspace contents are not modified · Issue #28475 · gradle/gradle · GitHub this might be caused by Anti-Virus disturbing.