格拉德尔: "Configuration cache state could not be cached"


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)

这是我在与等级同步时收到的错误消息,请帮助我解决这个问题

在文件gradle.properties中有一行代码org.gradle.unsafe.configuration-cache=true删除它并重新生成项目,它将解决问题。

出现这种情况的原因是Gradle的配置缓存。有些库是不可缓存的,因此会出现错误。

虽然上面的答案在技术上是正确的,但它宁愿隐藏问题,也不愿正确解决问题。

Gradle团队提出了一个非常酷的功能,帮助节省了几十秒甚至几分钟的时间;配置";阶段配置缓存类似于构建缓存,但对于。。。配置步骤。有时需要一段时间。

因此,关闭它是有效的,但它会增加您的构建时间。配置缓存可以在每次没有更改构建文件而只更改实际代码时使用。你知道吗?我们公司95%的案例都是这样。因此,我们在每次构建时都会通过打开它来节省1-2分钟。

如何?这需要一些工作。幸运的是,Gradle的人写了一个很好的循序渐进的指导。因此,如果您有一些时间执行技术任务,我绝对建议您尝试为所有或至少部分任务配置此功能:渐变配置缓存指令

相关内容

最新更新