fbjni: fbjni-0.5.0-headers.jar responds in 404
Issue description
When deploying our React Native 0.70.6 app to Android through Fastlane we’re now getting failed builds with the following error;
* Where:
Build file 'node_modules/react-native-mmkv/android/build.gradle' line: 322
* What went wrong:
Execution failed for task ':react-native-mmkv:extractAARHeaders'.
> Could not resolve all files for configuration ':react-native-mmkv:extractHeaders'.
> Could not find fbjni-0.5.0-headers.jar (com.facebook.fbjni:fbjni:0.5.0).
Searched in the following locations:
https://repo.maven.apache.org/maven2/com/facebook/fbjni/fbjni/0.5.0/fbjni-0.5.0-headers.jar
Code example
When looking through https://repo.maven.apache.org/maven2/com/facebook/fbjni/fbjni we see that the headers file is missing only for version 0.5.0.
https://repo.maven.apache.org/maven2/com/facebook/fbjni/fbjni/0.5.0/fbjni-0.5.0-headers.jar responds in 404.
System Info
Deployment from Linux CI env. using Fastlane.
About this issue
- Original URL
- State: closed
- Created a year ago
- Reactions: 14
- Comments: 16 (6 by maintainers)
0.5.1 will be hitting Maven Central in the next minutes.
We’ll follow up with more guidance on how to patch the affected libraries in the near future
Same with
react-native-vision-camera
.You can use mmkv version 2.6.0+ as, from what I can see, does have a “+” dependency.
You can use
patch-package
to unblock this build failure and edit those two lines to:but again, 0.4.0 might not be the right version you need.
This is not a breaking change. Also this library doens’t follow semantic versioning as it’s on a 0.x release schedule.
The core of the problem is that a library (mmkv, quick-crypto) is telling you to depend on “any” version of fbjni. So whenever you build, you’ll get the latest version of fbjni available. As we update fbjni, we can offer compatibility with all the react native versions, just because mmkv or quick-crypto used a “+” dependency. It’s up to that libraries to specify the version of their dependencies and don’t use dynamic ranges.
That’s exactly what I was explaining in my previous comments @zakus thanks for stressing it again.
There is no single fix for this, but it depends on a case by case basis:
api
dependency onfbjni
so the library should not need to specify any versions of fbjni at all but it will use the right versions provided by React Native. This is what mmkv is doing from 2.6+Thanks for the report. The
-headers
artifact is effectively missing, I’ll look into it.At the same time, the fact that
mmkv
had a dependency on fbjni with version “+” is a huge problem for you @stiltet-gofore and other users https://github.com/mrousavy/react-native-mmkv/blob/8e9231c3588336fec18769ca2dcb23d4030eeaea/android/build.gradle#L157-L160I can publish the
-header
artifact, and your build will be green, but your app may crash at runtime as FBJNI 0.5.0 has been built with NDK 25, which will most likely be higher than the NDK version you’re using in the rest of your setup.@cortinico deeply appreciate for your quick reply.
About this, could you teach us how to fix the fbjni version to
0.4.0
? maybe at least we could patch the library temporarilyhttps://github.com/mrousavy/react-native-mmkv/blob/8e9231c3588336fec18769ca2dcb23d4030eeaea/android/build.gradle#L157-L160
Hey! I just published react-native-vision-camera 2.15.5 which fixes those issues!
In react-native-mmkv and react-native-quick-crypto, those issues are already fixed in the latest version 😃
Thanks for giving me a head up about this!
The more global issue with those libraries (mmkv, quick-crypto) is that they try to use one version of headers, but react-native may use different version. In my case, for example, in ./node_modules/react-native/ReactAndroid/build.gradle react-native has
But in ./node_modules/react-native-mmkv/android/build.gradle, the react-native-mmkv module. has:
i.e. the latest version, until today it was 0.4.0.
Hard-coding 0.4.0 version in the mmkv gradle file in this case would fix build, but indeed may lead to a crash, since headers do not correspond to the actual library used. The correct way is for mmkv to use exactly the same version as used by react-native.
But question is, how the proper fix for those libraries would look, how to get the current version of fbjni that is used by react-native, from the mmkv gradle script?
@cortinico We already reported the issue here https://github.com/margelo/react-native-quick-crypto/issues/185. But it seems strange that we have a breaking change that doesn’t allow probably, thousand of apps to build, and it needs multiple libraries to release a new version to get it working again. I think we are missing backward-compatibility in some changes here.
Same issue with
react-native-quick-crypto