Skip to content

Commit 58f7618

Browse files
committed
fixes find_library when deployed external storage
Fixes `find_library()` `OSError`/`FileNotFoundError` exception when app deployed external SD storage. Apps deployed on external SD storage have different root prefix. External SD storage apps root dir prefix is like: ``` /mnt/expand/<sd-card-id>/user/0/<package.domain>.<package.name>/files/app ``` While internal storage apps root dir prefix is: ``` /data/data/<package.domain>.<package.name>/files/app ``` Hence the `[0:4]` trick doesn't work.
1 parent 5a3ed06 commit 58f7618

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

pythonforandroid/recipes/python2/patches/ctypes-find-library-updated.patch

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ index 52b3520..01b13a9 100644
1212
+if True:
1313
+ def find_library(name):
1414
+ # Check the user app lib dir
15-
+ app_root = os.path.abspath('./').split(os.path.sep)[0:4]
15+
+ app_root = os.path.abspath('../../').split(os.path.sep)
1616
+ lib_search = os.path.sep.join(app_root) + os.path.sep + 'lib'
1717
+ for filename in os.listdir(lib_search):
1818
+ if filename.endswith('.so') and name in filename:

0 commit comments

Comments
 (0)