Android Sdl2 Gradle Template Save Abandoned

Project README

This repository is no longer maintained.

This is being left up for reference but be warned it no longer builds on the modern Android toolchain.



This is an example project for using libSDL2 ( in an Android Gradle project. This project came about as I couldn't find a good example project using libSDL2 in a gradle project. This project will create 2 shared NDK libraries, libSDL2 and libmain, the latter containing a very basic SDL2 program which displays a blue square on a red screen.


  • JDK and JRE 8 (I have been using Debian 8 using jessie-backports to get openjdk-8-jre and openjdk-8-jdk)
  • Android SDK and NDK (with Android Build-tools 24.0.2 and Android Platform API 23, though these are configurable)
  • ANDROID_HOME and ANDROID_NDK_HOME environment variables set (I did this in /etc/environment)

Before you begin

I have not tested this in Android studio, I have just tested this using the Gradle wrapper command line. It is using gradle-experimental plugin version 0.8.0-beta3 and gradle version 2.14.1.


Download libSDL2 from the website ( Copy the src and include directories from the libSDL2 source into SDL2/ so you end up with the following directories:


We also need to copy the example Java file from the libSDL2 source code into our project at the following location (copy from SDL2-2.0.4/android-project/src/org/libsdl/app/


Compiling the app

./gradlew :SDL2:distributeLib

This will compile libSDL2 as a shared library.

./gradlew :main:distributeLib

This will compile our little project (source code in main/src/) as a shared library. You can now skip this step and just run assembleDebug as below. What I would suggest is you compile SDL2 first, commit it to source control, then just build the project as normal (assembleDebug).

./gradlew assembleDebug

This will build our apk's and output them to app/build/outputs/apk/.


The example libSDL2 program which draws the square on screen was found at

This guide was incredibly useful while I tried to figure out how to get this working:

The Google NDK example projects were very helpful:

Open Source Agenda is not affiliated with "Android Sdl2 Gradle Template" Project. README Source: stephen47/android-sdl2-gradle-template
Open Issues
Last Commit
2 years ago

Open Source Agenda Badge

Open Source Agenda Rating