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 2839

Summary: No way to create pre-built libraries for Android
Product: SDL Reporter: Mark Callow <libsdl.org>
Component: buildAssignee: Gabriel Jacobo <gabomdq>
Status: RESOLVED FIXED QA Contact: Sam Lantinga <slouken>
Severity: normal    
Priority: P2 CC: gabomdq
Version: 2.0.3   
Hardware: x86_64   
OS: Other   
Attachments: Script to build android version of SDL2.
Patch to Android.mk adding SDL2_main module

Description Mark Callow 2015-01-09 06:34:05 UTC
Created attachment 1985 [details]
Script to build android version of SDL2.

This is really an RFE but there is no way set that in this bugzilla.

README-android says to copy or link the SDL source tree to the jni folder in your Android project. It is not desirable to have to compile SDL with every application; furthermore the Android NDK has support for prebuilt libraries.

Attached is script (to be put in build-scripts) that builds the Android version of the libraries. The script builds both the existing SDL2 module and a new SDL2_main module. This is a static library containing the code from src/main/android/SDL_android_main.c. Also attached is a patch for Android.mk adding this module.

Note that when building an application's native .so using this prebuilt libSDL2main, you must use a link option, such as --whole-archive, that forces inclusion of the code in the .so because the functions in SDL_android_main are called only from Java.
Comment 1 Mark Callow 2015-01-09 06:35:04 UTC
Created attachment 1986 [details]
Patch to Android.mk adding SDL2_main module
Comment 2 Mark Callow 2015-01-09 06:39:44 UTC
P.S. The addition of SDL2_main to Android.mk won't affect any existing users because the Android build system defaults to building only the loadable (shared library) modules it finds in the .mk files. To build the new module, it must be explicitly specified to the build system, something the new script does.
Comment 3 Sam Lantinga 2017-08-14 01:00:18 UTC
This has been added, thanks!
https://hg.libsdl.org/SDL/rev/8e5441ab6c63