SDL2 on Android phones


Is there anyone using the SDL2 on Android devices pleasse ? If yes, do you have any suggestion on a good tutorial / description / reading material, where I could learn how to do it?

I am using SDL2 on MS Windows and I would like to try a port to Android device.

Thanks a lot

I used LazyFoo’s tutorial for Android Studio, but it’s quite outdated now:

I used LazyFoo’s tutorial for Android Studio, but it’s quite outdated now:

Lazy Foo' Productions - Hello Mobile

@SeanOConnor Thanks a lot. I see the last update of the tutorial is “6/10/19” - 2 years does not look that horrible… I am going to try it.

Any tips? Anything I should be aware / avoid it? I have not done anything for Android since the Android 2.2 Froyo…


The Lazy Foo tutorial did not work. After 4 hours I gave up trying. The error I got is:

[CXX1405] error when building with ndkBuild using D:\future\sdl\android-sdl-lib\SDL2-2.0.20\android-project\app\jni\ Build command failed.
Error while executing process D:\future\sdl\android-sdk\ndk\21.4.7075529\ndk-build.cmd with arguments {NDK_PROJECT_PATH=null APP_BUILD_SCRIPT=D:\future\sdl\android-sdl-lib\SDL2-2.0.20\android-project\app\jni\ NDK_APPLICATION_MK=D:\future\sdl\android-sdl-lib\SDL2-2.0.20\android-project\app\jni\ APP_ABI=armeabi-v7a NDK_ALL_ABIS=armeabi-v7a NDK_DEBUG=1 NDK_OUT=D:\future\sdl\android-sdl-lib\SDL2-2.0.20\android-project\app\build\intermediates\cxx\Debug\715o494s/obj NDK_LIBS_OUT=D:\future\sdl\android-sdl-lib\SDL2-2.0.20\android-project\app\build\intermediates\cxx\Debug\715o494s/lib APP_PLATFORM=android-16 APP_SHORT_COMMANDS=false LOCAL_SHORT_COMMANDS=false -B -n}

D:/future/sdl/android-sdk/ndk/21.4.7075529/build//../build/core/ Android NDK: Module main depends on undefined modules: SDL2    
D:/future/sdl/android-sdk/ndk/21.4.7075529/build//../build/core/ *** Android NDK: Note that old versions of ndk-build silently ignored this error case. If your project worked on those versions, the missing libraries were not needed and you can remove those dependencies from the module to fix your build. Alternatively, set APP_ALLOW_MISSING_DEPS=true to allow missing dependencies.    .  Stop.

If you search that problem on Internet you will find many people mentions that problem. I decided to not use SDL2 on Android. It seems to not be properly maintained.


I note that the android-project directory at SDL GitHub was changed only 18 days ago, and the build.gradle file there was updated 2 months ago. So it seems that is being maintained at least.

As far as my own app is concerned, I have deliberately not updated SDL since 2.0.10 and I am careful not to allow Android Studio to update itself, so I hope that will mean my Android build process continues to work.

I got stuck on LazyFoo’s step 11. I made the mistake of updating Android Studio to Arctic Fox and it now no longer seems to ask for an import destination directory so I didn’t know how to proceed from there.

I got around it by copying and pasting one of my existing games project’s folder, rebuilding the symlinks to SDL, and renaming anything I could find to my new game’s name. I’m still using 2.0.18 though.

Sorry I can’t help with your error message you’re getting. I’ve been programming games since the 80s and I make a living from them now but I don’t understand arcane Android Studio error messages! All I can guess is maybe when it’s saying APP_PLATFORM=android-16 does that mean you’re using an old SDK level and it needs to be upped?

Don’t give up yet.

We’re gonna get some better/modern mobile tutorials.

For now checkout this one larger RPG that was ported to android via SDL2:

Android port · flareteam/flare-engine Wiki (

@ theweirdn8
Three points:

1) Thanks for answer.
I really appreaciare that.

2) FlareRPG
I checked the - wow! What is impressive, but honestly also a kind of scary is – if I understand it correctly based on Blog posts – that the work on the game starts in 2010!

I have checked a bit the engine code and Git Wiki - again nice and impressive.

One think I found interesting is mentioned in Code Conventions · flareteam/flare-engine Wiki · GitHub and it says “No C++11 / C++0x” - Flare has a presence on obscure platforms. What are obscure platforms?

I might have similar approach by enforcing c++03 and no exceptions, no RTTI.

3) Don’t give up yet.

I will not, but I simply do not have time and taste to spend time finding what is wrong with SDL and Android. I expected the out-of-the-box support… I know I am naive.

I will come back to that at some point, but now Windows and MAC is more important for me. I am quite strict on separating the game code from the device dependant code (and SDL), so when the Android time come I could try in the worst case changing SDL for SFML (not sure if that is better) or try to manage it directly with Andoid NDK and its NativeActivity… But it’s months from today.

Hi, I’m the lead developer for Flare.

Don’t be too scared. Flare, like most open source projects, is a hobby. So development isn’t rigorous 100% of the time.

I think the most obscure ones I know of are ports on Haiku and Amiga OS4. Sticking with C++98 helps us keep things fairly portable for systems with older compilers.

As for the Android port, it still feels like black magic to me. Like @rtrussell mentioned, the android-project directory from SDL is a good template. If you’re using C++, make sure to set APP_STL and potentially APP_CPPFLAGS in your (example).

I am desperately trying to find some kind of simple framework that will let me port my audio editor in C++ to android. I was hoping SDD2 would let me draw waveforms and nice text to the android screen and to do hit detection on it. I got it running on windows but I can’t find any frameworks to work on android though I am way out of my depth on NDK and the build process it uses. I have tried a number of different tutorials including the LazyFoo tutorial which also crashed and burned until I gave up on it. I just need a basic example of something that works and explains the scavenger hunt to build the Rub Goldberg machine that NDK seems to be. Any suggestions for totals either with or without SDL2 it seems such a pity that some many programmers do so much work but no one can use most projects at least I can’t. So any luck on a new SDL2 tutorial for Android? Any general Advice on NDK and simple graphics ?

It’s hard to know what your issues are. I’m using SDL2 on Android and successfully create the kind of graphics you describe using a custom version of the SDL2_gfx library.

My Android build, which is based on the LazyFoo tutorial, ‘just works’. Admittedly I got it going some years ago and I have avoided updating Android Studio since, for fear of it breaking and being in exactly the same position you are!

Can you be more specific about what doesn’t work?