Wiki Page Content

Revision 1 as of 2014-06-18 21:42:07

Clear message

Building SDL2 for Android

First, a lot of information can be found in SDL2/README-android.txt.

The following offers simple walkthroughs to compile SDL Android apps.


  • Install minimal Java environment. For instance, in Debian/Ubuntu:

    sudo apt-get install openjdk-7-jdk ant
  • Install NDK (tested with r9d)
  • Install the latest SDK, run android and install API 12

Test 1: SDL wrapper for simple programs

  • Compile a sample app (calls ndk-build):

     cd /usr/src/SDL2/build-scripts/
     ./ org.libsdl.testgles ../test/testgles.c
  • Follow the instructions to install on your device:

     cd /usr/src/SDL2/build/org.libsdl.testgles/
     ant debug install


  • triple taret armeabi/armeabi-v7a/x86 compilation!
  • application doesn't quit

Test 2: SDL wrapper + SDL_image

First, modify showimage.c to show a simple embedded image (e.g. XPM).

To compile:

 cd /usr/src/SDL2/build-scripts/
 ./ org.libsdl.showimage /usr/src/SDL2_image/showimage.c
 cd /usr/src/SDL2/build/org.libsdl.showimage/
 ln -s /usr/src/SDL2_image jni/
 ln -s /usr/src/SDL2_image/external/libwebp-0.3.0 jni/webp
 # - Edit jni/
 # - Edit android-project/src/org/libsdl/app/
 #   System.loadLibrary("SDL2_image");
 # - Edit jni/ remove x86 where jpeg-9 doesn't build
 ndk-build -j$(nproc)
 ant debug install


  • application doesn't restart properly
Please include your contact information if you'd like to receive a reply.