Support third-party 64-bit libraries on Android
Problem
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: All new apps and app updates that include native code are required to provide 64-bit versions in addition to 32-bit versions when publishing to Google Play. Extension: Google Play will continue to accept 32-bit only updates to existing games that use Unity 5.6 or older until August 2021. Starting August 1, 2021: Google Play will stop serving apps without 64-bit versions on 64-bit capable devices, meaning they will no longer be available in the Play Store on those devices. This will include games built with Unity 5.6 or older. The requirement does not apply to: APKs or app bundles explicitly targeting Wear OS or Android TV, which are form factors that do not currently support 64-bit code. APKs or app bundles that are not distributed to devices running Android 9 Pie or later. 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: 1. Create a new application with `react-native init`. 2. In the "android/app/build.gradle" file, add `compile 'io.realm:realm-android:0.82.2'` to the end of the `dependencies {}` b
Error Output
Error: could find DSO to load: libreactnativejni.so
Unverified for your environment
Select your OS to check compatibility.
1 Fix
Add 64-bit Support for React Native on Android
The issue arises because the React Native framework does not include a 64-bit version of the `libreactnativejni.so` library by default. This is a requirement for apps targeting 64-bit devices, as Google Play will not serve apps without 64-bit support on those devices. The absence of this library leads to compatibility issues when integrating React Native with other libraries that require 64-bit support.
Awaiting Verification
Be the first to verify this fix
- 1
Update React Native Version
Ensure you are using a version of React Native that supports 64-bit libraries. As of version 0.59 and later, React Native includes 64-bit support. Upgrade your React Native version if necessary.
bashnpm install --save react-native@latest - 2
Modify build.gradle for ABI Filters
In your `android/app/build.gradle` file, ensure that the ABI filters include both 'armeabi-v7a' and 'arm64-v8a' to support 32-bit and 64-bit architectures.
groovyndk { abiFilters 'armeabi-v7a', 'arm64-v8a' } - 3
Rebuild the Project
After making changes to the `build.gradle` file, clean and rebuild your project to ensure that the new configurations are applied.
bash./gradlew clean && ./gradlew assembleRelease - 4
Test on 64-bit Device
Deploy the updated application to a 64-bit device or emulator to verify that the `libreactnativejni.so` library is correctly loaded and the application runs without errors.
bashadb install path/to/your/app.apk - 5
Publish to Google Play
Once validated, prepare your app for release and publish it to Google Play, ensuring that both 32-bit and 64-bit versions are included.
bash./gradlew publish
Validation
To confirm the fix worked, check that the application successfully loads on a 64-bit device without errors related to `libreactnativejni.so`. Additionally, verify that the APK contains both 32-bit and 64-bit libraries by inspecting the APK contents using Android Studio or command-line tools.
Sign in to verify this fix
Environment
Submitted by
Alex Chen
2450 rep