From 9c0fcf51389fe2fb8b710a50f42d63e4b784badc Mon Sep 17 00:00:00 2001 From: Ankit Agrawal Date: Thu, 18 Dec 2025 09:01:49 +0530 Subject: [PATCH] Fixed for library loader in SoLoader sdk. Adding all supported abi path to load library from apk lib/[abi]/ Currently its adding path only for first supported abi. Due to this, few apps Lego Builder and Lingo Kids apps which uses library from arm64-v8a, but Soloader tries to load from first supported abi x86_64. Signed-off-by: Ankit Agrawal --- .../facebook/soloader/DirectApkSoSource.java | 20 +++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/java/com/facebook/soloader/DirectApkSoSource.java b/java/com/facebook/soloader/DirectApkSoSource.java index ecf1b04..e2ed068 100644 --- a/java/com/facebook/soloader/DirectApkSoSource.java +++ b/java/com/facebook/soloader/DirectApkSoSource.java @@ -120,16 +120,16 @@ public String getLibraryPath(String soName) throws IOException { Set directApkPathSet = new HashSet<>(); final String apkPath = aInfo.sourceDir; - final @Nullable String fallbackApkLdPath = getFallbackApkLdPath(apkPath); - if (fallbackApkLdPath != null) { - directApkPathSet.add(fallbackApkLdPath); + final @Nullable Set fallbackApkLdPath = getFallbackApkLdPath(apkPath); + if (fallbackApkLdPath != null && fallbackApkLdPath.size() != 0) { + directApkPathSet.addAll(fallbackApkLdPath); } if (aInfo.splitSourceDirs != null) { for (String splitApkPath : aInfo.splitSourceDirs) { - final @Nullable String fallbackSplitApkLdPath = getFallbackApkLdPath(splitApkPath); - if (fallbackSplitApkLdPath != null) { - directApkPathSet.add(fallbackSplitApkLdPath); + final @Nullable Set fallbackSplitApkLdPath = getFallbackApkLdPath(splitApkPath); + if (fallbackSplitApkLdPath != null && fallbackSplitApkLdPath != 0) { + directApkPathSet.addAll(fallbackSplitApkLdPath); } } } @@ -137,7 +137,7 @@ public String getLibraryPath(String soName) throws IOException { return directApkPathSet; } - private static @Nullable String getFallbackApkLdPath(String apkPath) { + private static @Nullable Set getFallbackApkLdPath(String apkPath) { final String[] supportedAbis = SysUtil.getSupportedAbis(); if (apkPath == null || apkPath.isEmpty()) { LogUtil.w( @@ -152,7 +152,11 @@ public String getLibraryPath(String soName) throws IOException { + ((supportedAbis == null) ? "null" : "empty")); return null; } - return apkPath + "!/lib/" + supportedAbis[0]; + Set apkLdPaths = new HashSet<>(); + for (String supportedAbi : supportedAbis) { + apkLdPaths.add(apkPath + "!/lib/" + supportedAbi); + } + return apkLdPaths; } private void loadDependencies(