-
Notifications
You must be signed in to change notification settings - Fork 24.4k
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
Support third-party 64-bit libraries on Android #2814
Comments
Thanks for reporting! Yes we don't provide 64-bit version of the native code and the system should always fall back to 32-bit. I believe @kmagiera has context on why we don't provide 64-bit version. |
Like the stackoverflow answer says, the fallback doesn't work if there are other 64-bit native libraries. Most Android projects use a number of 3rd-party libraries, and any that include native 64-bit code will cause React Native to fail. I think that Android's policy on this is strange (the way one library is loaded shouldn't affect another that doesn't depend on it), but as you can see if you follow my steps to reproduce, it does in fact fail. As more libraries switch to native 64-bit support and React Native gets used in more heterogeneous projects this will become more of an issue. |
It definitely matters as all native libs share address space. Workaround would be to follow build.grade from our examples and add the following block to
|
Yeah, I tested with that |
I've uploaded an example failing project here, in case it helps with debugging. The only changes to the default React-Native-generated project are the addition of the README and the addition of the |
Furthermore, I can confirm that installing the apk in 32-bit mode works on the nexus 9, as found in this SO answer ( |
I figured out a workaround in the short term (disabling all ARM64 binaries) and wrote it up in a blog. However, the right solution definitely needs to be proper ARM64 support, because that's the way the device ecosystem is moving). If it isn't included because of concerns over binary size, maybe switching to the packaged V8 interpreter would help? Any ARM64 devices should come with it included, and perhaps falling back to the vendored JSC for devices where V8 isn't available could work. |
The fragmentation of running on different JS VMs is worth avoiding. It already kind of sucks that iOS 7/8/9 support different features, and the JS VM should be only a couple MB anyway. Can ABI splits be used to address concerns about APK size? The idea is that you generate three APKs for 32bit, 64bit, simulator, and distribute them separately. |
@ide yes, splits can be used to keep size down, although Google doesn't recommend it: "Although we encourage you to develop and publish a single APK that supports as many device configurations as possible, doing so is sometimes not possible" (emphasis theirs). I think a reasonable solution would be to generate a monolithic APK by default with x86/arm/arm64 support, and allow individual developers to go through the hassle of producing multiple APKs if their app requires it. I don't think that just ignoring ARM64 will be a good long-term compromise -- it will become harder and harder to use 3rd-party libraries with React Native as more include ARM64 support and more 64-bit devices come to market. |
I kind of understand Google's solution though that's how Apple operated for almost a decade and they're moving to architecture-/device-specific binaries (but doing it all for you with their bitcode compiler).
I like this solution as a starting point. Things to track for 64-bit support are:
All of these are up-for-grabs. @kmagiera can you tell us if 64-bit is something that Facebook is actively interested in, or should people just start working on these items? |
@ide I don't think we have anyone focusing on this at the moment. What are the specific things that doesn't compile for armv8? Except from JSC we build all the first-party and third-party libs RN depends on with BUCK for arm64 so it shouldn't take much to make android makefiles build them as well. Speaking of split builds I don't think Google's recommendation apply in the case when 80% of the APK size comes from native libs. Don't have exact values with me at the moment but from what I remember JSC lib is around 2.3M for armv7 and 2.5M for x86 (uncompressed) which adds around 1.3M to the APK size. Considering the fact that arm64 are quite rare and all of them can run armv7 binaries (JSC with JIT enabled doesn't work with libhoudini if I recall correctly from our experiments, so I consider x86 android devices incapable of running armv7 in this case) I don't think we should default to armv7+arm64+x86 builds. My suggestion would be still to default to x86+armv7 but provide config for split builds for arm64 once it's supported |
@kmagiera - OK. So if people are interested in 64-bit support they should contribute. I hit an issue with Google's double-conversion library but I could have specified the wrong compiler options. I didn't spend much time looking into it. |
@ide feel free to send PR, I'll update here once we start working on this but I don't expect this to happen within the next couple of weeks. |
FWIW Facebook does ABI apk splitting (and others). Whenever we ship we ship ~14 apks to the store. Out of that 14 we had a fallback that supported everything (no splitting) but virtually no device ever installed it because the others were sufficient. |
Hi, |
@Matthew-C I haven't heard any updates. If you need this feature, please help out! |
@Matthew-C This workaround might unblock you (see the discussion above): https://corbt.com/posts/2015/09/18/mixing-32-and-64bit-dependencies-in-android.html |
+1 on this, our product has some 64bit dependencies as well |
@corbt thank you for publishing the workaround, works fine! https://corbt.com/posts/2015/09/18/mixing-32-and-64bit-dependencies-in-android.html |
Hi there! This issue is being closed because it has been inactive for a while. But don't worry, it will live on with ProductPains! Check out its new home: https://productpains.com/post/react-native/android-react-native-for-android-is-incompatible-with-3rd-party-64-bit-libraries ProductPains helps the community prioritize the most important issues thanks to its voting feature. Also, if this issue is a bug, please consider sending a PR with a fix. |
Isn't react-native |
@afilp check the release notes: https://github.com/facebook/react-native/releases/tag/v0.59.0 |
The latest release is currently 0.59.2. There is not yet a 0.60. |
Indeed, I meant to say " |
Summary: add arm64 support, related issue : facebook/react-native#2814. If we are okay with binary aar android-jsc, then the pr can be directly merged. Otherwise merge facebookarchive/android-jsc#30 first and do a new release. RNTester all variant works. You can also test the apk from here: https://github.com/gengjiawen/react-native/releases/tag/v0.56beta. facebookarchive/android-jsc#30. [ANDROID] [ENHANCEMENT] [ABI] - add x86_64 arm64-v8a support. Differential Revision: D9491481 Pulled By: hramos fbshipit-source-id: d6ec6992768eb0c0866a0317273e09fae5b8935e
Does this means that all the react native apps will have to upgrade their RN version to 0.0.59 or higher for pushing any update to play store starting August 1st, 2019? |
I'm getting the following warning: |
@AdamZaczek after upgrade to RN 0.59 try to add x64 build config on
To make sure there's no missing library try to decompress apk, and open |
You can use this tool to know what changed in the project files that are not dependencies thus not automatically updated when updating RN, e.g.: |
this worked for me |
I have several Apps with RN 0.54.2. Is there no way I can get a 64bit version without upgrading to 0.59? I've tried a couple times to upgrade with rn-diff-purge or |
My react native version is 0.59 but my app is not working on android 9 after downloading from play store. I followed the @prrenish way but id didn't worked for me. Also i generated Android App Bundle of my app and uploaded to google play console but app still on working on android 9. |
Anyone please update on the question of @Dror-Bar ? I also have the same question. |
By the way, I needed to update from version 0.55.4 to 0.59.8. So, I finally decided to just initialise a new project with the latest version, then simply copy my src folder, make the necessary package updates from there, then run Android Studio and Xcode and see that it compiles successfully . Surprisingly, while I still had to update a few 3rd party packages, this ended up being a much cleaner and easier solution. |
Summary: add arm64 support, related issue : facebook#2814. If we are okay with binary aar android-jsc, then the pr can be directly merged. Otherwise merge facebookarchive/android-jsc#30 first and do a new release. RNTester all variant works. You can also test the apk from here: https://github.com/gengjiawen/react-native/releases/tag/v0.56beta. facebookarchive/android-jsc#30. [ANDROID] [ENHANCEMENT] [ABI] - add x86_64 arm64-v8a support. Differential Revision: D9491481 Pulled By: hramos fbshipit-source-id: d6ec6992768eb0c0866a0317273e09fae5b8935e
Add line from this answer:
Alternatively it can be (the same):
Then create your build using this command:
It will create Android App Bundle file, located at:
Upload This steps solved my issue. Hope it will help someone. |
@zmefz |
@IagorM I think it has to do with React Native 0.59+ which supports 64 bit (you can see it supports arm64-v8a and x86_64 in addition to armeabi-v7a and x86 in android/app/build.gradle). I believe ABB is only to reduce overall APK size by creating a bundle that Goole Play later chooses just the necessary libraries to install on the device. |
I solved this issue by changing my Rest API URL from "http" to "https". If your API URL type is "http" it will not work on android 9. By changing to "https" my app is working fine now. |
This article seems to work for me, esp the part about "Better solution" |
Excerpt from the Android Developers Blog article, Get your apps ready for the 64-bit requirement:
[added by @hramos]
The 64-bit requirement: what it means for developers
Starting August 1, 2019:
Starting August 1, 2021:
The requirement does not apply to:
Original Issue
Hey, it appears that React Native on Android doesn't provide a 64-bit version of the
libreactnativejni.so
native library, which can cause compatibility issues on 64-bit devices. I ran into this while attempting to integrate React Native with a large existing application I'm developing.Steps to reproduce:
react-native init
.compile 'io.realm:realm-android:0.82.2'
to the end of thedependencies {}
block. (Note that I don't think this is an issue specifically caused by Realm, it's just an example dependency with a 64-bit native library).Stack trace:
I believe this to be caused by the shared library loading logic explained in this answer on StackOverflow. Since Realm includes a 64-bit native binary, the system no longer automatically falls back to the 32-bit version of
libreactnativejni.so
provided by React.This bug is blocking me from integrating React Native into my existing application, which I'm really excited to try!
The text was updated successfully, but these errors were encountered: