gradle fails with Problems reading data from Binary store error
AndroidGradleAndroid Problem Overview
I have a Gradle file that runs the tests. It does not build anything. All it has is a unzip task that extracts all jars in a Gradle configuration into a particular directory and then runs the task of type Test. This test task points the testClasses directory to the location where the previous copy task has extracted the configuration into.
My build fails with the error message:
> Problems reading data from Binary store
When I run 'gradle dependencies' it does not show any error/warning When I run the copy task individually, it runs very well fine. Only when I run everything it fails with error :
> Could not resolve all dependencies for configuration ':testConfig'.$
> Problems reading data from Binary store in /tmp/gradle8793563212642185736.bin (exist: false)$
I see the file /tmp/gradle8793563212642185736.bin
does not exist. What could be the reason for this?
Android Solutions
Solution 1 - Android
In my case setting org.gradle.parallel=false
flag fixes the issue, but it's not a solution for my project, flag increase CI build time from ~15min to ~45min.
Solution 2 - Android
I solved upgrading following packages to last version (06/02/2021), so:
project app-level build.gradle
file:
com.google.firebase:firebase-analytics:17.2.2
to
com.google.firebase:firebase-analytics:18.0.2
Project-level build.gradle file:
com.google.gms:google-services:4.3.3
to
com.google.gms:google-services:4.3.5
Solution 3 - Android
It happened with Flutter development in my case. Apparently, it is not an actual issue and there is no magic fix. Cleaning build file with "Flutter clean" and restarting the command line executer window solved the issue.
Solution 4 - Android
I was working with version 5.x earlier and then I upgraded to 6.0.1 and it resolved the issue. this is how you can upgrade
cd android
./gradlew clean
./gradlew wrapper --gradle-version 6.0.1
./gradlew -v # to download the new version
cd ..
flutter clean
flutter run # might take 15 - 20mins for the first time
Solution 5 - Android
Turns out it was just a network problem for me. Gradle just needed to connect to the internet.
Solution 6 - Android
There are mainly a few steps to solve this problem.
- Go to gradle.properties and set
org.gradle.parallel=false
and sync. Make sure your sync gradle offline option is off - Start the build with this option. If it's a big project setting
org.gradle.parallel=false
will take a long time. - Cancel the build repeat the steps setting
org.gradle.parallel=true
.
Also do not turn on offline build
Solution 7 - Android
This solution worked in my flutter project. I solved it by making these changes:
- In android level build.gradle file, replace
classpath 'com.android.tools.build:gradle:3.5.4'
withclasspath 'com.android.tools.build:gradle:4.0.1'
(basically upgrade the version from 3.5.4 to 4.0.1) - In gradle-wrapper.properties file, replace
distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.2-all.zip
withdistributionUrl=https\://services.gradle.org/distributions/gradle-6.1.1-all.zip
(upgrade from 5.6.2 to 6.1.1)
and if you have added classpath 'com.google.gms:google-services:4.3.3'
to android level build.gradle file, replace that too with classpath 'com.google.gms:google-services:4.3.5'
(upgrade from 4.3.3 to 4.3.5)
Solution 8 - Android
In my case the writing problem was there was no enough storage to build the app so I needed to restart my Mac and it finished building successfully.
I know am too late but it might help someone in the future so
Solution 9 - Android
Start by upgrading Gradle to the latest version.
Binary store issues reported to GitHub are often fixed right away, especially if they include a Minimal, Reproducible Example.
If upgrading didn't work, it can be useful to run the task again with Performance options disabled:
--no-parallel
--no-configure-on-demand
Next please find an existing issue or open a new one so it can be fixed in future versions. These things are all helpful:
- Minimal, Reproducible Example
- Build Scan
- Smallest change that introduced the problem (e.g. worked on 5.5, but not 5.6)
Solution 10 - Android
I ended up here after publishing an artifact to mavenLocal()
.
I tried a lot but in the end what helped me was:
- Upgrading gradle from 6.3 to 6.9
./gradlew wrapper --gradle-version 6.9
Hope this saves me half an hour next time this occurs.
Solution 11 - Android
Thanks to Cedric's hint, stopping gradle offline mode and make it online, fixed the issue for me