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

Summary: Android: loading native libs directly from apk generated by bundletool
Product: SDL Reporter: akk0rd87 <amkad87>
Component: *don't know*Assignee: Ryan C. Gordon <icculus>
Status: RESOLVED FIXED QA Contact: Sam Lantinga <slouken>
Severity: normal    
Priority: P2 CC: amkad87, sylvain.becker
Version: HG 2.1   
Hardware: All   
OS: Android (All)   
Attachments: Patch to fix this bug
Patch with SDL_strrchr and without check "*(library_name + 1)"
Patch with SDL_strrchr and without check "*(library_name + 1)"

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