I am trying to run my first SDL hello-world project on android. I use the android project template provided in SDL source package, it use a class called SDLActivity to communicate with android and native c/c++ code. I import them into Eclipse android project, then slightly modify AndroidManifest.xml, Application.mk in folder jni, and Android.mk in folder jni/src .
The project compiled successfully. But when it runs on simulator (I use GenyMotion), I got error message in logcat.
E/SDLActivity(1472): Failed loading eglChooseConfig: Invalid library handle
I also try to debug on a real device. I got this message:
E/SDLActivity(28020): Failed loading eglChooseConfig: dlsym library handle is null
I tried to add "System.loadLibrary("EGL");" in SDLActivity.java . Not work.
Here is my Android.mk in jni/src
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE := main
SDL_PATH := ../SDL
LOCAL_C_INCLUDES := $(LOCAL_PATH)/$(SDL_PATH)/include
# Add your application source files here...
LOCAL_SRC_FILES := $(SDL_PATH)/src/main/android/SDL_android_main.c \
main.cpp
LOCAL_SHARED_LIBRARIES :=SDL2
LOCAL_LDLIBS := -lGLESv1_CM -lGLESv2 -llog -lEGL
include $(BUILD_SHARED_LIBRARY)
I eventually found a good tutorial on youtube. I followed this video and my app works fine. I've tested my app on virtual and real devices.
Here is the sample code used by the youtube recorder. I am not the author of the code below. Just put a copy here.
This code will let you know how to initialize SDL on android. There is one thing needs to take care of: version of openGL ES needs to set correctly. For example, I use openGLES 1.1, so I change
to