Wiki Page Content

Differences between revisions 3 and 4
Revision 3 as of 2014-06-19 20:35:48
Size: 1773
Revision 4 as of 2014-06-20 17:25:58
Size: 1777
Comment: Fix path to
Deletions are marked like this. Additions are marked like this.
Line 45: Line 45:
 # - Edit jni/  # - Edit jni/src/

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

  • Configure your environment variables, e.g.:


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 target 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/src/
 # - 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

None: Android (last edited 2018-11-21 16:00:50 by SylvainBeucler)

Please include your contact information if you'd like to receive a reply.