Skip to content

jarchen/sdl2_on_android

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 

Repository files navigation

SDL2 on Android

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.

Environment

  • OS: Ubuntu 12.04 64-bit
  • NDK: r9d

Download

  • SDL2 source code download from here.

Steps:

  1. Copy android-project from ${SDL2_SOURCE}/android-project to other location (ex: ${your_path}/android-project).

  2. 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/"
    
  3. 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;
    }
    
  4. Change "YourSourceHere.c" to yours (ex: "main.c") which defined in ${your_path}/android-project/jni/src/Android.mk

  5. Compile SDL2 library by ndk tool.

    cd ${your_path}/android-project/
    ${NDK_PATH}/ndk-build
    
  6. Create a java file extends SDLActivity like MainActivity.java.

Notes:

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

Start to develop your SDL application.

About

Porting SDL2 on Android Devices

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published