Configuration cache state could not be cached: field 'actions' from type 'org.gradle.api.DefaultTask': error writing value of type 'java.util.ArrayList'
> Configuration cache state could not be cached: field 'closure' from type 'org.gradle.api.internal.AbstractTask$ClosureTaskAction': error writing value of type 'com.chaquo.python.PythonPlugin$_createAssetsTasks_closure21$_closure46'
> Configuration cache state could not be cached: field 'variant' from type 'com.chaquo.python.PythonPlugin$_createAssetsTasks_closure21$_closure46': error writing value of type 'groovy.lang.Reference'
> Configuration cache state could not be cached: field 'value' from type 'groovy.lang.Reference': error writing value of type 'com.android.build.gradle.internal.api.ApplicationVariantImpl'
> Configuration cache state could not be cached: field 'testVariant' from type 'com.android.build.gradle.internal.api.ApplicationVariantImpl': error writing value of type 'com.android.build.gradle.internal.api.TestVariantImpl'
> Configuration cache state could not be cached: field 'variantData' from type 'com.android.build.gradle.internal.api.TestVariantImpl': error writing value of type 'com.android.build.gradle.internal.variant.TestVariantData'
> Configuration cache state could not be cached: field 'testedVariantData' from type 'com.android.build.gradle.internal.variant.TestVariantData': error writing value of type 'com.android.build.gradle.internal.variant.ApplicationVariantData'
> Configuration cache state could not be cached: field 'artifacts' from type 'com.android.build.gradle.internal.variant.ApplicationVariantData': error writing value of type 'com.android.build.api.artifact.impl.ArtifactsImpl'
> Configuration cache state could not be cached: field 'storageProvider' from type 'com.android.build.api.artifact.impl.ArtifactsImpl': error writing value of type 'com.android.build.api.artifact.impl.StorageProviderImpl'
> Configuration cache state could not be cached: field 'fileStorage' from type 'com.android.build.api.artifact.impl.StorageProviderImpl': error writing value of type 'com.android.build.api.artifact.impl.TypedStorageProvider'
> Configuration cache state could not be cached: field 'singleStorage' from type 'com.android.build.api.artifact.impl.TypedStorageProvider': error writing value of type 'java.util.LinkedHashMap'
> java.util.ConcurrentModificationException (no error message)
This is the error message I am receiving while synchronizing with the gradle please help me solving this issue
2
Answers
In the file
gradle.properties
there is a line of codeorg.gradle.unsafe.configuration-cache=true
Delete it and rebuild the project, it will solve the problem.This occurred due to the configuration cache of Gradle. Some libraries are not cacheable so it gives the error .
While the answer above is technically correct, it’s rather hiding an issue than properly solving it.
Gradle team came up with a pretty cool feature helping to save some tens of seconds or even minutes on the "Configuration" phase. Configuration cache is something like a Build cache but for… configuration steps. And sometimes they take a while.
So, turning it off works but it increases your build times. Configuration cache can be used every time when you haven’t changed your build files and only changed the actual code. And you know what? It’s like 95% of cases in our company. So, we save 1-2 minutes on every build by having it on.
How? It requires some work. Luckily, Gradle folks wrote a nice step-by-step instruction. So, if you have some time for technical tasks, I would definitely recommend trying to configure this thing for all or at least some of your tasks:
Gradle Configuration Cache instruction