[ANDROID] SoLoader error using App Bundle
Problem
๐ Bug Report Please help! There are some crashes happening in android using app bundle but I am not sure how to reproduce it. It happens on our app with daily crash of 200 users. [code block] The errors have multiple variations that occur on various android versions. [code block] [code block] [code block] To Reproduce We have tried to reproduce it with many devices but we can only reproduce it in one condition. 1. Install the release app 2. Upgrade OS from 32bit to 64bit 3. Open the app If we reinstall the app afterwards, it works fine. Although, we are still unsure whether it is the only error case. Expected Behavior The app does not crash on any device. Code Example [code block] Environment [code block]
Error Output
Exception: java.lang.UnsatisfiedLinkError: couldn't find DSO to load: libreactnativejni.so
Unverified for your environment
Select your OS to check compatibility.
1 Fix
Fix SoLoader UnsatisfiedLinkError in App Bundle
The error occurs due to the SoLoader not being able to locate the native library 'libreactnativejni.so' after an OS upgrade from 32-bit to 64-bit. This is likely due to the app bundle not correctly loading native libraries in the new architecture context, leading to crashes when the app is launched.
Awaiting Verification
Be the first to verify this fix
- 1
Update SoLoader Initialization
Ensure that SoLoader is initialized correctly in your MainApplication.java. This includes specifying the correct native library paths and ensuring that the libraries are loaded for both 32-bit and 64-bit architectures.
javaSoLoader.init(this, /* native exopackage */ false); - 2
Add ABI Filters
Modify your build.gradle file to include ABI filters for the architectures you want to support. This ensures that the correct native libraries are packaged with your app bundle.
groovyandroid { defaultConfig { ndk { abiFilters 'armeabi-v7a', 'arm64-v8a', 'x86', 'x86_64' } } } - 3
Rebuild the App Bundle
After making the changes, rebuild your app bundle to ensure that the new configurations are applied. Use the command below to generate the new app bundle.
bash./gradlew bundleRelease - 4
Test on Multiple Devices
Deploy the updated app bundle to multiple devices with different architectures and Android versions to ensure that the issue is resolved. Pay special attention to devices that previously experienced the crash.
bashadb install -r app-release.aab - 5
Monitor Crash Reports
After deployment, monitor crash reports from users to confirm that the issue has been resolved. Use tools like Firebase Crashlytics to track any remaining crashes related to SoLoader.
bashfirebase crashlytics:log 'Monitoring SoLoader crashes'
Validation
Confirm the fix by checking that no new crashes related to 'libreactnativejni.so' occur in the crash reports after the app update. Additionally, verify that the app runs smoothly on devices that previously experienced the issue.
Sign in to verify this fix
Environment
Submitted by
Alex Chen
2450 rep