nativeRunMain(): Couldn't find function SDL_main in library libmain.so

I’ve been trying to follow the README-android page here. I’m using the Gradle project template, not androidbuild.sh.

I’ve followed all of the steps, except for the parts that mention CMake, since I’m running directly from Android Studio.

The game is able to compile and install to the device, but will not boot because of that error.

The Android.mk file is linking these libraries:

LOCAL_SHARED_LIBRARIES := SDL2 SDL2_image

I tried adding LOCAL_STATIC_LIBRARIES := SDL2main too, but the same error occurs when the game is run.

The game is able to run on other targets successfully, like Windows and Emscripten, so the main function seems fine.

What else am I missing here?

I should have specified versions. I’m using:

  • SDK Build Tools version 34.0.0
  • NDK version 25.1.8937393 (it forces me to download and use this version)
  • Platform tools version 35.0.1
  • SDL 2.30.3

I updated to the latest version of Android Studio, and now it gets me to download NDK 26 instead of 25. When doing so, Android Studio will throw an error saying:

[CXX1110] Platform version 19 is unsupported by this NDK. Please change minSdk to at least 21 to avoid undefined behavior.

If I change minSdkVersion to 21 in my build.gradle file, the app now compiles successfully and I get the same error mentioned in the OP about nativeRunMain().

I suspect there’s an NDK version issue going on here.