From 58f7618b839fa6ad47014e42f7b727f5ebc7ca5c Mon Sep 17 00:00:00 2001 From: Andre Miras Date: Sun, 3 Jun 2018 23:41:26 +0200 Subject: [PATCH] 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//user/0/./files/app ``` While internal storage apps root dir prefix is: ``` /data/data/./files/app ``` Hence the `[0:4]` trick doesn't work. --- .../recipes/python2/patches/ctypes-find-library-updated.patch | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pythonforandroid/recipes/python2/patches/ctypes-find-library-updated.patch b/pythonforandroid/recipes/python2/patches/ctypes-find-library-updated.patch index b12d7a8a40..07221cc43f 100644 --- a/pythonforandroid/recipes/python2/patches/ctypes-find-library-updated.patch +++ b/pythonforandroid/recipes/python2/patches/ctypes-find-library-updated.patch @@ -12,7 +12,7 @@ index 52b3520..01b13a9 100644 +if True: + def find_library(name): + # Check the user app lib dir -+ app_root = os.path.abspath('./').split(os.path.sep)[0:4] ++ app_root = os.path.abspath('../../').split(os.path.sep) + lib_search = os.path.sep.join(app_root) + os.path.sep + 'lib' + for filename in os.listdir(lib_search): + if filename.endswith('.so') and name in filename: