We are currently migrating Bugzilla to GitHub issues.
Any changes made to the bug tracker now will be lost, so please do not post new bugs or make changes to them.
When we're done, all bug URLs will redirect to their equivalent location on the new bug tracker.

Bug 4739 - Android: loading native libs directly from apk generated by bundletool
Summary: Android: loading native libs directly from apk generated by bundletool
Status: RESOLVED FIXED
Alias: None
Product: SDL
Classification: Unclassified
Component: *don't know* (show other bugs)
Version: HG 2.1
Hardware: All Android (All)
: P2 normal
Assignee: Ryan C. Gordon
QA Contact: Sam Lantinga
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2019-07-25 17:18 UTC by akk0rd87
Modified: 2019-07-27 18:23 UTC (History)
2 users (show)

See Also:


Attachments
Patch to fix this bug (1.27 KB, patch)
2019-07-25 17:35 UTC, akk0rd87
Details | Diff
Patch with SDL_strrchr and without check "*(library_name + 1)" (1.25 KB, patch)
2019-07-26 04:00 UTC, akk0rd87
Details | Diff
Patch with SDL_strrchr and without check "*(library_name + 1)" (1.27 KB, text/plain)
2019-07-26 04:33 UTC, akk0rd87
Details

Note You need to log in before you can comment on or make changes to this bug.
Description akk0rd87 2019-07-25 17:18:50 UTC
Starting with Android 6.0. native libs may not be extracted to filesystem when they was built without compression by bundletool and in this case they should be loaded directly from APK.

That is why we should pass to dload in nativeRunMain only library name without path, i.e. *.so filename.

There is a discourse https://discourse.libsdl.org/t/android-bundle-and-nativelibrarydir-returned-by-getmainsharedobject/26424/8

If you want to check if your libs extracted or not you may use Native Libs Monitor: https://play.google.com/store/apps/details?id=com.xh.nativelibsmonitor.app
Comment 1 akk0rd87 2019-07-25 17:35:19 UTC
Created attachment 3898 [details]
Patch to fix this bug

When deploying android app bundle format uncompressed native libs may not extract from apk to filesystem. In this case we should use lib name without path.
Comment 2 Sylvain 2019-07-25 21:24:03 UTC
Yes, seems OK to me.

Simply:
- Use SDL_strrchr in place of strrchr
- unneeded check for "*(library_name + 1)"...


I need to check and commit. Can do that in  a few days..
Comment 3 akk0rd87 2019-07-26 04:00:23 UTC
Created attachment 3899 [details]
Patch with SDL_strrchr and without check "*(library_name + 1)"
Comment 4 akk0rd87 2019-07-26 04:33:43 UTC
Created attachment 3900 [details]
Patch with SDL_strrchr and without check "*(library_name + 1)"

Patch to fix.

Diff with prev patch version:
1. SDL_strrchr instead of strrchr;
2. Removed check "*(library_name + 1)";
3. "library_name = library_name + 1" instead of "++library_name" (may be not all C compilers support ++ operation).
Comment 5 Sylvain 2019-07-27 18:23:56 UTC
Thanks! applied in https://hg.libsdl.org/SDL/rev/131ea7dcc225