Configuration Cache Incompatibility: cleanCmakeCache Task Causes "Cannot reference a Gradle script object" Error on Clean Build #7007
Labels
Missing info
The user didn't precise the problem enough
Missing repro
This issue need minimum repro scenario
Platform: Android
This issue is specific to Android
./gradlew clean error!
I'm encountering an issue with the react-native-reanimated package that causes a build failure when Gradle's configuration cache is enabled, specifically when performing a clean build (./gradlew clean). The error message indicates an incompatibility with the way the cleanCmakeCache task is configured in the react-native-reanimated's build.gradle file.
Crucially, this issue only occurs on a clean build. Subsequent builds after the initial failure succeed.
Error Message
`Execution failed for task ':react-native-reanimated:cleanCmakeCache'.
Expected Behavior
The build should succeed with the configuration cache enabled, even on a clean build. The cleanCmakeCache task should be compatible with the configuration cache.
Observed Behavior
The build fails with the "Cannot reference a Gradle script object from a Groovy closure" error only on a clean build. This error is caused by the following line in react-native-reanimated/android/build.gradle (around line 453):
task cleanCmakeCache() { tasks.getByName("clean").dependsOn(cleanCmakeCache) doFirst { delete "${projectDir}/.cxx" // this is line 453 } }
Attempts to Resolve
I have tried several approaches to resolve this issue, but none have been successful:
Environment
Gradle: 8.8
Operating System: macOS 14.1
Request
I would greatly appreciate it if the maintainers of react-native-reanimated could investigate this issue and provide a fix that is compatible with Gradle's configuration cache, especially on clean builds.
Steps to reproduce
Create a new React Native project or use an existing one.
Install the react-native-reanimated package: npm install react-native-reanimated or yarn add react-native-reanimated.
Enable the configuration cache in your gradle.properties file:
org.gradle.configuration-cache=true
Perform a clean build: ./gradlew clean
The build will fail with the error message mentioned above.
If i make a normal build: ./gradlew assembleDebug or ./gradlew assembleRelease.
The build will succeed
Snack or a link to a repository
https://snack.expo.dev/
Reanimated version
3.15.3
React Native version
0.75.3
Platforms
Android
JavaScript runtime
Hermes
Workflow
React Native
Architecture
Paper (Old Architecture)
Build type
Other (please specify)
Device
None
Device model
No response
Acknowledgements
Yes
The text was updated successfully, but these errors were encountered: