Fix loadLibraries() failing for 64bit arch#1701
Conversation
|
Nice investigation and thank you for the PR. I guess we ne to test it at least on ARMv7 to see it didn't introduce a regression |
|
👍 On armv7, I haven't seen anything odd so far due to the changes, and I will inform in case I notice anything while using my builds. |
|
I've tested this with arm 7 and 8 and both apps ran without issue that I could see. it also fixed #1719 on arm 8 for me. |
OptimusGREEN
left a comment
There was a problem hiding this comment.
This fixes arm v8 builds for me and have seen no detrimental effects in arm 7a after several successful builds.
|
Thanks, and also to @OptimusGREEN for the testing. |
|
@inclement yeah I would assume both the original python 2 ctypes patch (not my work) and my rip-off variant for python 3 would break in armv8. since pyjnius doesn't depend on ctypes, the best approach I can think of is to use that to access this java function inside our ctypes patch |
loadLibraries()fails in loading native libs whenarchisarm64-v8aorx86_64.Explanation
On 64-bit Android, the path obtained by
getFilesDir().getParentFile().getAbsolutePath() + "/lib"(e.g./data/data/<package>/lib) is not available (ref.; I did verify this on my 64-bit Android devices). For the same reason,libsDirPathingetLibraries()below is resolved to a non-existent path:python-for-android/pythonforandroid/bootstraps/sdl2/build/src/main/java/org/kivy/android/PythonUtil.java
Lines 34 to 38 in e7c1117
As a result, in
addLibraryIfExists(), aNullPointerExceptionis thrown atfiles.length. (Note thatlistFiles()returnsnullfor an invalid directory path per this ref.)python-for-android/pythonforandroid/bootstraps/sdl2/build/src/main/java/org/kivy/android/PythonUtil.java
Lines 17 to 21 in e7c1117
Although this exception is being caught, native libs (libSDL.so, libmain.so, etc.) are not loaded, so Android crashes anyway:
Fix
Use
getApplicationInfo().nativeLibraryDirinstead, which is officially documented.