SDL is very popular and usefull library for rendering video, playin audio, and handling keyboard, mouse, and joystick events, etc. For helping the person, who want to use SDL to develop any applications. This project is going to give the instruction for proting SDL2 library on Android devices.
- OS: Ubuntu 12.04 64-bit
- NDK: r9d
- SDL2 source code download from here.
-
Copy android-project from ${SDL2_SOURCE}/android-project to other location (ex: ${your_path}/android-project).
-
Create SDL folder and copy files into ${your_path}/android-project/.
mkdir "${your_path}/android-project/jni/SDL" cp -r "${SDL2_SOURCE}/src" "${your_path}/android-project/jni/SDL/" cp -r "${SDL2_SOURCE}/include" "${your_path}/android-project/jni/SDL/" cp "${SDL2_SOURCE}/Android.mk" "${your_path}/android-project/jni/SDL/"
-
Create a new c/c++ file (ex: main.c) under ${your_path}/android-project/jni/src/ and define main function like following
// main.c #include "SDL.h" int main (int argc, char** argv) { // Some sdl code here return 0; }
-
Change "YourSourceHere.c" to yours (ex: "main.c") which defined in ${your_path}/android-project/jni/src/Android.mk
-
Compile SDL2 library by ndk tool.
cd ${your_path}/android-project/ ${NDK_PATH}/ndk-build
-
Create a java file extends SDLActivity like MainActivity.java.
You can set the platforms you want to build for. Bulding platforms are defined by APP_ABI
in ${your_path}/android-project/jni/Application.mk