Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

React-Native Android build is failing with error - Task :react-native-mmkv:prepareBoost FAILED #617

Closed
gangadharuseline opened this issue Jan 1, 2024 · 14 comments

Comments

@gangadharuseline
Copy link

gangadharuseline commented Jan 1, 2024

I am trying to run npx react-native run-android
The build is failing with the below error,
PFA screenshot
Screenshot 2024-01-02 at 1 07 02 AM

Below is the some of the log

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':react-native-mmkv:prepareBoost'.
> Could not read /Users/gangadhar/Documents/Workspaces/Useline/beem-app/node_modules/react-native-mmkv/android/build/downloads/boost_1_76_0.tar.gz.
   > Not in GZIP format

* Try:
> Run with --stacktrace option to get the stack trace.
> Run with --info or --debug option to get more log output.
> Run with --scan to get full insights.

* Get more help at https://help.gradle.org

BUILD FAILED in 1m 7s

    at makeError (/Users/gangadhar/Documents/Workspaces/Useline/beem-app/node_modules/execa/index.js:174:9)
    at /Users/gangadhar/Documents/Workspaces/Useline/beem-app/node_modules/execa/index.js:278:16
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async runOnAllDevices (/Users/gangadhar/Documents/Workspaces/Useline/beem-app/node_modules/@react-native-community/cli-platform-android/build/commands/runAndroid/runOnAllDevices.js:109:5)
    at async Command.handleAction (/Users/gangadhar/Documents/Workspaces/Useline/beem-app/node_modules/@react-native-community/cli/build/index.js:192:9)
info Run CLI with --verbose flag for more details.

Here are Our App's few package.json versions are

"react": "18.0.0",
"react-native": "0.69.12",
"react-native-mmkv": "2.5.1",

Note: IOS app works fine.

Can you please help us here

@deepanshu-sharma09
Copy link

deepanshu-sharma09 commented Jan 2, 2024

Have you been able to resolve this??

Execution failed for task ':react-native-mmkv:prepareBoost'.
> Could not read /.../App/node_modules/react-native-mmkv/android/build/downloads/boost_1_76_0.tar.gz.
   > Not in GZIP format

@Kavahardik
Copy link

Execution failed for task ':react-native-mmkv:prepareBoost'.

Could not read /Users/peer/Documents/V3.1/Dipon/DiponMerchant/node_modules/react-native-mmkv/android/build/downloads/boost_1_76_0.tar.gz.
Not in GZIP format

Facing same issue.

@buiphuclam
Copy link

try remove node_modules, reinstall and mrousavy/react-native-vision-camera#1489 (comment)

@gangadharuseline
Copy link
Author

gangadharuseline commented Jan 2, 2024

@deepanshu-ample @Kavahardik
Yes, The issue was fixed to me.

What i did is,
Actually I use nvm to manage my node,
Earlier I am using the node version => v16.20.2
Now I had installed latest node lts version i.e v20.10.0
After pointing to node version => v20.10.0 - I am not seeing the above prepareBoost issue
our app runs successfully

@ajay-mandaviya
Copy link

Facing same issue :
"react": "18.1.0", "react-native": "0.70.6", "react-native-mmkv": "2.5.1",
node version: v20.6.1
`* What went wrong:
Execution failed for task ':react-native-mmkv:prepareBoost'.

Could not read /Project-path/node_modules/react-native-mmkv/android/build/downloads/boost_1_76_0.tar.gz.
Not in GZIP format`
Getting same error in react-native-reanimated

@ajay-mandaviya
Copy link

@deepanshu-ample @Kavahardik

Yes, The issue was fixed to me.
What i did is, Actually I use nvm to manage my node, Earlier I am using the node version => v16.20.2 Now I had installed latest node lts version i.e v20.10.0 After pointing to node version => v20.10.0 - I am not seeing the above prepareBoost issue our app runs successfully

Updating node version to v20.10.0 run successfully ✅ 🚀

@deepanshu-sharma09
Copy link

For developers using older versions of Realm (realm/realm-js#5136), consider utilizing Node version v18.19.0.

@anirudh-antino
Copy link

@gangadharuseline You can download boost_1_76_0.tar.gz file from here https://source.ipfire.org/source-2.x/
In your case you can download it via this link: https://source.ipfire.org/source-2.x/boost_1_76_0.tar.gz

then just copy it to App/node_modules/react-native-mmkv/android/build/downloads/boost_1_76_0.tar.gz and build your app.

Note: you need to do this every time you run yarn or npm. I usually do this since since it downloads this file every time and it is very slow to download.

@brianwestphal
Copy link

brianwestphal commented Jan 8, 2024

@vasudhakorva
Copy link

@deepanshu-ample @Kavahardik

Yes, The issue was fixed to me.
What i did is, Actually I use nvm to manage my node, Earlier I am using the node version => v16.20.2 Now I had installed latest node lts version i.e v20.10.0 After pointing to node version => v20.10.0 - I am not seeing the above prepareBoost issue our app runs successfully

Updating node version to v20.10.0 run successfully ✅ 🚀

We are facing the same issue . In which file did u add the node version

@alexanderhodes
Copy link

alexanderhodes commented Jan 8, 2024

The problem that you're facing is related to the general problem in the React Native Community regarding the broken download url from JFrog.
The React Native team is already working on a solution for it. You can follow the complete progress in this issue.

A temporary fix that worked on my build have been these steps:

  1. Install patch-package
npm install --save-dev patch-package postinstall-postinstall
  1. Modify build.gradle

You can find this file locally on your machine here: node_modules/react-native-mmkv/android/build.gradle

Change this line:

task downloadBoost(dependsOn: createNativeDepsDirectories, type: Download) {
  def transformedVersion = BOOST_VERSION.replace("_", ".")

  // change this line
  def srcUrl = "https://boostorg.jfrog.io/artifactory/main/release/${transformedVersion}/source/boost_${BOOST_VERSION}.tar.gz"
  // to this
  def srcUrl = "https://archives.boost.io/release/${transformedVersion}/source/boost_${BOOST_VERSION}.tar.gz"
  if (REACT_NATIVE_VERSION < 69) {
    srcUrl = "https://github.com/react-native-community/boost-for-react-native/releases/download/v${transformedVersion}-0/boost_${BOOST_VERSION}.tar.gz"
  }
  src(srcUrl)
  onlyIfNewer(true)
  overwrite(false)
  dest(boost_file)
}
  1. Create patch

You need to run npx patch-package react-native-mmkv to create the patch which will be applied. This will generate a patch file in the patches/ folder in your project.

  1. Add postinstall script to package.json

You need to app the following script into your package.json

"scripts": {
     "postinstall": "patch-package"
}

Afterwards, you can commit all files. This should fix your broken build. These changes will be applied automacially in your CI/ CD pipeline as well. There's no need to change this on every commit or push.

The steps are inspired by this post

@retyui
Copy link

retyui commented Jan 9, 2024

patch-package patch

diff --git a/node_modules/react-native-mmkv/android/build.gradle b/node_modules/react-native-mmkv/android/build.gradle
index 13eae76..bc8dc83 100644
--- a/node_modules/react-native-mmkv/android/build.gradle
+++ b/node_modules/react-native-mmkv/android/build.gradle
@@ -204,7 +204,7 @@ task createNativeDepsDirectories {

 task downloadBoost(dependsOn: createNativeDepsDirectories, type: Download) {
   def transformedVersion = BOOST_VERSION.replace("_", ".")
-  def srcUrl = "https://boostorg.jfrog.io/artifactory/main/release/${transformedVersion}/source/boost_${BOOST_VERSION}.tar.gz"
+  def srcUrl = "https://archives.boost.io/release/${transformedVersion}/source/boost_${BOOST_VERSION}.tar.gz"
   if (REACT_NATIVE_VERSION < 69) {
     srcUrl = "https://github.com/react-native-community/boost-for-react-native/releases/download/v${transformedVersion}-0/boost_${BOOST_VERSION}.tar.gz"
   }

@mrousavy
Copy link
Owner

mrousavy commented Jan 9, 2024

Instead of creating patches as comments, could you maybe create a PR so I can merge this upstream? Thanks

@mrousavy
Copy link
Owner

the latest MMKV version (2.11) does not have this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests