SDL2 for Android API level 19

SDL2 example application works without problem with newer Androids API 21+. The problem was with API level 19. It took me some time to figure out reasons for very interesting errors.

Let’s examine error messages and investigate how to fix them.

When I’ve started sdl2-android-example on a device with API 19, it failed with error message: dlopen failed: cannot locate symbol “signal” referenced by”

The root cause is not that obvious from the error message. It failed because the application has been built for API 21 instead of API 19.

The fixture is easy, just set sdkVersion to 19.

For this purpose, I’ve extracted sdkVersion to settings.gradle which can be found in the root directory of the project.

gradle.ext.sdkVersion = 19

Each module then has reference to this value:

model {
    android {
        compileSdkVersion = gradle.sdkVersion

Make complete clean and distributeLib to rebuild for proper API.

gradle clean dL

Hooray! Fixed. Let’s start the application.

Yey. New error: dlopen failed: could not load library “” needed by “”; caused by cannot locate symbol “png_set_longjmp_fn” referenced by “”

The root cause of this issue is similar to the problem with JPEG described in the previous article. Paul Asiimwe found out that there is another library the name png and it has a different version so the application crashes.

To fix this issue it was necessary to rename whole png submodule to SDL2_png. Renaming requires clean and new distributeLib:

gradle clean dL

After these small tricks, the sdl2-android-example works even with API level 19.

No votes yet.
Please wait...

1. September 2017 at 18:48 - Development (Tags: , , , , ). Both comments and pings are currently closed.

Comments are closed.