SDL2 on Android phones

Hello,

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
STeN

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

http://lazyfoo.net/tutorials/SDL/52_hello_mobile/index.php

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…

Regards,
STeN

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\Android.mk: 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\Android.mk NDK_APPLICATION_MK=D:\future\sdl\android-sdl-lib\SDL2-2.0.20\android-project\app\jni\Application.mk 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/build-binary.mk:651: Android NDK: Module main depends on undefined modules: SDL2    
D:/future/sdl/android-sdk/ndk/21.4.7075529/build//../build/core/build-binary.mk:664: *** 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.

Regards,
STeN

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 (github.com)