Add /system_ext/lib64 to SoLoader default system library search paths
Summary: SoLoader hardcodes /system/lib64 and /vendor/lib64 as its system library search paths, but omits /system_ext/lib64 (or 32-bit equivalents). This causes SO’s not to be found for any native library installed in /system_ext/, even though Android’s own linker namespace includes /system_ext by default.
Meta wearable products install Meta-specific native libraries to /system_ext/ partition. So currently in order to be able to look up libraries that are not bundled with the APK, wearable apps individually have to add /system_ext/lib64 as a directory source.
Why fix in SoLoader instead of downstream:
- 15 callsites already carry individual workarounds for this same gap, and any future apps that need /system_ext/ will have to do the same
- The Android linker already includes /system_ext/lib64 in its default namespace — SoLoader should match
Why this is safe:
- DirectorySoSource handles nonexistent directories gracefully: getSoFileByName() calls File.exists(), returns null if the directory doesn’t exist, and SoLoader moves on to the next source
- /system_ext was introduced in Android 11; on older devices where it doesn’t exist, the path is silently skipped
Reviewed By: adicatana
Differential Revision: D100731500
fbshipit-source-id: f8455187bc3d5f571698879cbd8d06a9719103c1
SoLoader
SoLoader is a native code loader for Android. It takes care of unpacking your native libraries and recursively loads dependencies on Android API 23 and earlier, since those old OS versions do not support all of that functionality out of box.
Requirements
SoLoader is useful for applications running on Android API 23 and earlier. SoLoader should not be used on Android API 24 and above unless the app is delivered as Exopackage, requires Android Native Library Merging or uses Superpack compression.
Including SoLoader in your apps
You can use prebuilt aars or fetch SoLoader from Maven repository by adding the following to your
build.gradlefile:Building from source
To build SoLoader from source you’ll need Buck. Once you have Buck installed execute following commands from the project root directory:
The build command generates
buck-out/gen/soloader.aarfile.Join our community
Please use our issues page to let us know of any problems. See the CONTRIBUTING file for how to help out.
License
SoLoader is Apache-2.0-licensed.