Wiki Page Content

Differences between revisions 2 and 3
Revision 2 as of 2014-06-19 20:35:19
Size: 1772
Comment: Configure PATH
Revision 3 as of 2014-06-19 20:35:48
Size: 1773
Comment:
Deletions are marked like this. Additions are marked like this.
Line 31: Line 31:
 * triple taret armeabi/armeabi-v7a/x86 compilation!  * triple target armeabi/armeabi-v7a/x86 compilation!

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.

Pre-requisites

  • 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.:

    PATH="$PATH:/usr/src/android-ndk-r9d"
    PATH="$PATH:/usr/src/android-sdk-linux/tools"

Test 1: SDL wrapper for simple programs

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

     cd /usr/src/SDL2/build-scripts/
     ./androidbuild.sh 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

Notes:

  • 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/
 ./androidbuild.sh 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/Android.mk
 #   LOCAL_SHARED_LIBRARIES := ... SDL2_image
 # - Edit android-project/src/org/libsdl/app/SDLActivity.java:
 #   System.loadLibrary("SDL2_image");
 # - Edit jni/Application.mk: remove x86 where jpeg-9 doesn't build
 ndk-build -j$(nproc)
 ant debug install

Notes:

  • application doesn't restart properly

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

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