Help with SDL and Android

Dear forum,

I have spent a frustrating couple of days trying to get a working SDL for Android and hoping someone might be able to help.

My final aim to compile an existing application (which already builds for Linux, Windows and OSX), for, ideally ICS. It uses SDL 1.2 [.10]. I would like to use native development, not an IDE. For the time being I’m happy to get the simplest of example code running.

My list of attempts:

(1) I first found http://jiggawatt.org/badc0de/android/index.html as it refered to SDL-1.2.13 and seemed easy enough to follow. the libSDL.a built fine, but when I try to link this with a sample.c I ge a whole bunch of ‘undefined references’

/home/files/android/SDL-1.2.13/src/SDL.c:101: undefined reference to SDL_StartTicks' /home/files/android/SDL-1.2.13/src/video/SDL_video.c:273: undefined reference toFBCON_bootstrap’

seeing that other ports of SDL seem to have better android hardware support I decided to abandon here.

(2) http://wilbefast.com/2011/07/29/sdl-for-android-in-10-drunken-steps/ refers to http://www.libsdl.org/tmp/android-project.zip so I tried this and successfully build both the libSDL and the sample ‘aliens’ test.

running on my Android device [Transformer Prime] bombs out with…

E/SurfaceTexture( 112): [SurfaceView] connect: already connected (cur=1, req=1)
E/libEGL ( 7606): EGLNativeWindowType 0xb46a68 already connected to another API
E/libEGL ( 7606): eglCreateWindowSurface:368 error 300b (EGL_BAD_NATIVE_WINDOW)
E/SDL ( 7606): Couldn’t create surface
I/>>> ERROR( 7606): Couldn’t create OpenGL context - see Android log for details

(3) reading that there might be issues with OGL_ES2, I set changes the SDL_android_config.h to

#define SDL_VIDEO_RENDER_OGL_ES2 0

this builds, but on the Transformer it bombs after loading the data files (see dump below)

(4) trying the same android-project on Android3.1, gives another coredump (see below)

(5) hg clone -u SDL-1.2 http://hg.libsdl.org/SDL SDL-1.2
… no sign of any android support

(6) hg clone -u SDL-1.3 http://hg.libsdl.org/SDL SDL-1.3
… no sign of any android support

(7) hg clone http://hg.libsdl.org/SDL
Ah! android-project et al…

followed through the README

No sign of SDL_mixer, or SDL_image so not a great start, also,
“WARNING: This code is under construction, may not build, and is unstable!”

and it’s SDL 2.0 and I don’t even really want to move to SDL 1.3

so abandoned and now hoping someone can help.----------------------------------------------------------------------

(dump from (3))

F/libc ( 7782): Fatal signal 11 (SIGSEGV) at 0x5c29073c (code=1)
D/dalvikvm( 480): GC_CONCURRENT freed 2036K, 37% free 12884K/20359K, paused 2ms+132ms
I/DEBUG ( 3203): *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
I/DEBUG ( 3203): Build fingerprint: 'asus/WW_epad/TF201:4.0.3/IML74K/WW_epad-9.4.2.15-20120221:user/release-keys’
I/DEBUG ( 3203): pid: 7782, tid: 7796 >>> org.libsdl.app <<<
I/DEBUG ( 3203): signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 5c29073c
I/DEBUG ( 3203): r0 00000028 r1 5b1f451c r2 5c29073c r3 5c08600a
I/DEBUG ( 3203): r4 5b1f3b9c r5 00000000 r6 000007f8 r7 fffffe00
I/DEBUG ( 3203): r8 000001ad r9 5b1f3b9c 10 00000384 fp 0000e200
I/DEBUG ( 3203): ip 00000000 sp 5b7c4a00 lr 5b1dcb83 pc 5b1dca5e cpsr 00000030
I/DEBUG ( 3203): d0 000084c000000000 d1 00000f7f4704c080
I/DEBUG ( 3203): d2 40dfae1440dfae14 d3 3f8000003f800000
I/DEBUG ( 3203): d4 4704c00000000000 d5 00000000000084c0
I/DEBUG ( 3203): d6 c393800000000000 d7 000000003f000000
I/DEBUG ( 3203): d8 0000000000000000 d9 0000000000000000
I/DEBUG ( 3203): d10 0000000000000000 d11 0000000000000000
I/DEBUG ( 3203): d12 0000000000000000 d13 0000000000000000
I/DEBUG ( 3203): d14 0000000000000000 d15 0000000000000000
I/DEBUG ( 3203): d16 4008000000000000 d17 7e37e43c8800759c
I/DEBUG ( 3203): d18 3ff0000000000000 d19 0000000000000000
I/DEBUG ( 3203): d20 0000000000000000 d21 0000000000000000
I/DEBUG ( 3203): d22 3ff0000000000000 d23 0000000000000000
I/DEBUG ( 3203): d24 3ff0000000000000 d25 0000000000000000
I/DEBUG ( 3203): d26 0000000000000000 d27 0000000000000000
I/DEBUG ( 3203): d28 0000000000000000 d29 0000000000000000
I/DEBUG ( 3203): d30 0000000000000000 d31 0000000000000000
I/DEBUG ( 3203): scr 20000012
I/DEBUG ( 3203):
I/DEBUG ( 3203): #00 pc 0005aa5e /data/data/org.libsdl.app/lib/libSDL.so
I/DEBUG ( 3203): #01 pc 0005ab7e /data/data/org.libsdl.app/lib/libSDL.so
I/DEBUG ( 3203): #02 pc 0005a058 /data/data/org.libsdl.app/lib/libSDL.so
I/DEBUG ( 3203): #03 pc 000684ca /data/data/org.libsdl.app/lib/libSDL.so (SDL_LowerBlit)
I/DEBUG ( 3203): #04 pc 00068672 /data/data/org.libsdl.app/lib/libSDL.so (SDL_UpperBlit)
I/DEBUG ( 3203): #05 pc 0000c04e /data/data/org.libsdl.app/lib/libSDL.so (SDL_UpdateRects)
I/DEBUG ( 3203): #06 pc 0000c106 /data/data/org.libsdl.app/lib/libSDL.so (SDL_UpdateRect)
I/DEBUG ( 3203): #07 pc 00001d62 /data/data/org.libsdl.app/lib/libmain.so (RunGame)
I/DEBUG ( 3203): #08 pc 000025d6 /data/data/org.libsdl.app/lib/libmain.so (SDL_main)
I/DEBUG ( 3203): #09 pc 00001a1e /data/data/org.libsdl.app/lib/libmain.so (Java_org_libsdl_app_SDLActivity_nativeInit)
I/DEBUG ( 3203): #10 pc 0001ec30 /system/lib/libdvm.so (dvmPlatformInvoke)
I/DEBUG ( 3203): #11 pc 00058f6c /system/lib/libdvm.so (_Z16dvmCallJNIMethodPKjP6JValuePK6MethodP6Thread)
I/DEBUG ( 3203):
I/DEBUG ( 3203): code around pc:
I/DEBUG ( 3203): 5b1dca3c 46819601 d9752d07 785f9801 370400ff …F.-u…_x…7
I/DEBUG ( 3203): 5b1dca4c 781f46bb 00fe3302 587f465f 587746bb .F.x.3…_F.X.FwX
I/DEBUG ( 3203): 5b1dca5c c280445f 00ff785f 46bb3704 3302781f _D…_x…7.F.x.3
I/DEBUG ( 3203): 5b1dca6c 465f00fe 46bb587f 445f5877 785fc280 …_F.X.FwX_D…_x
I/DEBUG ( 3203): 5b1dca7c 370400ff 781f46bb 00fe3302 587f465f …7.F.x.3…_F.X
I/DEBUG ( 3203):
I/DEBUG ( 3203): code around lr:
I/DEBUG ( 3203): 5b1dcb60 46c0bdf0 00017164 4902b510 f7ff4479 …Fdq…IyD…
I/DEBUG ( 3203): 5b1dcb70 bd10ff41 000171ac 4902b510 f7ff4479 A…q…IyD…
I/DEBUG ( 3203): 5b1dcb80 bd10ff39 0001799c 4902b510 f7ff4479 9…y…IyD…
I/DEBUG ( 3203): 5b1dcb90 bd10ff31 0001818c 4902b510 f7ff4479 1…IyD…
I/DEBUG ( 3203): 5b1dcba0 bd10ff29 0001897c 465fb5f0 464d4656 )…|…_FVFMF
I/DEBUG ( 3203):
I/DEBUG ( 3203): memory map around addr 5c29073c:
I/DEBUG ( 3203): 5c160000-5c1fe000
I/DEBUG ( 3203): (no map for address)
I/DEBUG ( 3203): 5c2b4000-5c380000
I/DEBUG ( 3203):
I/DEBUG ( 3203): stack:
I/DEBUG ( 3203): 5b7c49c0 400af85c
I/DEBUG ( 3203): 5b7c49c4 5b1b2529 /data/data/org.libsdl.app/lib/libSDL.so
I/DEBUG ( 3203): 5b7c49c8 00a9b480 [heap]
I/DEBUG ( 3203): 5b7c49cc 00af4910 [heap]
I/DEBUG ( 3203): 5b7c49d0 00000000
I/DEBUG ( 3203): 5b7c49d4 00000800
I/DEBUG ( 3203): 5b7c49d8 00b43a60 [heap]
I/DEBUG ( 3203): 5b7c49dc 400af35c
I/DEBUG ( 3203): 5b7c49e0 1e744000
I/DEBUG ( 3203): 5b7c49e4 40079314 /system/lib/libc.so
I/DEBUG ( 3203): 5b7c49e8 00b43a60 [heap]
I/DEBUG ( 3203): 5b7c49ec 400af35c
I/DEBUG ( 3203): 5b7c49f0 1e744000
I/DEBUG ( 3203): 5b7c49f4 40079314 /system/lib/libc.so
I/DEBUG ( 3203): 5b7c49f8 df0027ad
I/DEBUG ( 3203): 5b7c49fc 00000000
I/DEBUG ( 3203): #00 5b7c4a00 009c0328 [heap]
I/DEBUG ( 3203): 5b7c4a04 00000028
I/DEBUG ( 3203): 5b7c4a08 400af8b0
I/DEBUG ( 3203): 5b7c4a0c 00000000
I/DEBUG ( 3203): 5b7c4a10 00000000
I/DEBUG ( 3203): 5b7c4a14 5b7c4ae0
I/DEBUG ( 3203): 5b7c4a18 5b7c4ae0
I/DEBUG ( 3203): 5b7c4a1c 00a73df0 [heap]
I/DEBUG ( 3203): 5b7c4a20 00a714c0 [heap]
I/DEBUG ( 3203): 5b7c4a24 00000004
I/DEBUG ( 3203): 5b7c4a28 00000001
I/DEBUG ( 3203): 5b7c4a2c 5b1dcb83 /data/data/org.libsdl.app/lib/libSDL.so
I/DEBUG ( 3203): #01 5b7c4a30 00a73df0 [heap]
I/DEBUG ( 3203): 5b7c4a34 5b1dc05b /data/data/org.libsdl.app/lib/libSDL.so
W/InputDispatcher( 191): channel ‘41727c58 org.libsdl.app/org.libsdl.app.SDLActivity (server)’ ~ Consumer closed input channel or an error occurred. events=0x8
E/InputDispatcher( 191): channel ‘41727c58 org.libsdl.app/org.libsdl.app.SDLActivity (server)’ ~ Channel is unrecoverably broken and will be disposed!

(4) dump

I/ActivityManager( 155): Displayed org.libsdl.app/.SDLActivity: +466ms (total +2m8s250ms)
I/>>> Test( 2526): load()
I/DEBUG ( 85): *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
I/DEBUG ( 85): Build fingerprint: 'Lenovo/ThinkPadTablet/Indigo:3.1/ThinkPadTablet_A310_02/0024_0065_UK:user/release-keys’
I/DEBUG ( 85): pid: 2526, tid: 2535 >>> org.libsdl.app <<<
I/DEBUG ( 85): signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 5728f000
I/DEBUG ( 85): r0 0000001b r1 8077251c r2 5728f000 r3 56ef5766
I/DEBUG ( 85): r4 80771b9c r5 00000000 r6 000000f8 r7 ffff8100
I/DEBUG ( 85): r8 000001a4 r9 80771b9c 10 00000280 fp 00008100
I/DEBUG ( 85): ip 00000000 sp 593c0960 lr 8075ab83 pc 8075aafa cpsr 00000030
I/DEBUG ( 85): d0 000084c000000000 d1 4133f6684704c080
I/DEBUG ( 85): d2 0000000000000000 d3 3f8000003f800000
I/DEBUG ( 85): d4 4704c00000000000 d5 4127a530000084c0
I/DEBUG ( 85): d6 7e37e43c8800759c d7 4008000000000000
I/DEBUG ( 85): d8 0000000000000000 d9 0000000000000000
I/DEBUG ( 85): d10 0000000000000000 d11 0000000000000000
I/DEBUG ( 85): d12 0000000000000000 d13 0000000000000000
I/DEBUG ( 85): d14 0000000000000000 d15 0000000000000000
I/DEBUG ( 85): scr 20000012
I/DEBUG ( 85):
I/DEBUG ( 85): #00 pc 0005aafa /data/data/org.libsdl.app/lib/libSDL.so
I/DEBUG ( 85): #01 pc 0005ab7e /data/data/org.libsdl.app/lib/libSDL.so
I/DEBUG ( 85): #02 pc 0005a058 /data/data/org.libsdl.app/lib/libSDL.so
I/DEBUG ( 85): #03 pc 000684ca /data/data/org.libsdl.app/lib/libSDL.so (SDL_LowerBlit)
I/DEBUG ( 85): #04 pc 00068672 /data/data/org.libsdl.app/lib/libSDL.so (SDL_UpperBlit)
I/DEBUG ( 85): #05 pc 0000c04e /data/data/org.libsdl.app/lib/libSDL.so (SDL_UpdateRects)
I/DEBUG ( 85): #06 pc 0000c106 /data/data/org.libsdl.app/lib/libSDL.so (SDL_UpdateRect)
I/DEBUG ( 85): #07 pc 00001d62 /data/data/org.libsdl.app/lib/libmain.so (RunGame)
I/DEBUG ( 85): #08 pc 000025d6 /data/data/org.libsdl.app/lib/libmain.so (SDL_main)
I/DEBUG ( 85): #09 pc 00001a1e /data/data/org.libsdl.app/lib/libmain.so (Java_org_libsdl_app_SDLActivity_nativeInit)
I/DEBUG ( 85): #10 pc 00011c74 /system/lib/libdvm.so
I/DEBUG ( 85): #11 pc 00040ed2 /system/lib/libdvm.so (dvmCallJNIMethod_staticNoRef)
I/DEBUG ( 85): #12 pc 00046536 /system/lib/libdvm.so (dvmResolveNativeMethod)
I/DEBUG ( 85): #13 pc 00016e88 /system/lib/libdvm.so
I/DEBUG ( 85): #14 pc 0001bd54 /system/lib/libdvm.so (dvmMterpStd)
I/DEBUG ( 85): #15 pc 0001ae10 /system/lib/libdvm.so (dvmInterpret)
I/DEBUG ( 85): #16 pc 00057be8 /system/lib/libdvm.so (dvmCallMethodV)
I/DEBUG ( 85): #17 pc 00057c10 /system/lib/libdvm.so (dvmCallMethod)
I/DEBUG ( 85): #18 pc 0004bb76 /system/lib/libdvm.so
I/DEBUG ( 85): #19 pc 00011958 /system/lib/libc.so (__thread_entry)
I/DEBUG ( 85): #20 pc 000114ac /system/lib/libc.so (pthread_create)
I/DEBUG ( 85):
I/DEBUG ( 85): libc base address: aff00000
I/DEBUG ( 85):
I/DEBUG ( 85): code around pc:
I/DEBUG ( 85): 8075aad8 46bb587f 445f5877 785fc280 370400ff
I/DEBUG ( 85): 8075aae8 781f46bb 00fe3302 587f465f 587746bb
I/DEBUG ( 85): 8075aaf8 c280445f 3801785f 370400ff 781f46bb
I/DEBUG ( 85): 8075ab08 5876465e 587f00ff 330246b3 c280445f
I/DEBUG ( 85): 8075ab18 dc942800 2f004647 2001d018 44634240
I/DEBUG ( 85):
I/DEBUG ( 85): code around lr:
I/DEBUG ( 85): 8075ab60 46c0bdf0 00017164 4902b510 f7ff4479
I/DEBUG ( 85): 8075ab70 bd10ff41 000171ac 4902b510 f7ff4479
I/DEBUG ( 85): 8075ab80 bd10ff39 0001799c 4902b510 f7ff4479
I/DEBUG ( 85): 8075ab90 bd10ff31 0001818c 4902b510 f7ff4479
I/DEBUG ( 85): 8075aba0 bd10ff29 0001897c 465fb5f0 464d4656
I/DEBUG ( 85):
I/DEBUG ( 85): stack:
I/DEBUG ( 85): 593c0920 aff467e8
I/DEBUG ( 85): 593c0924 80730529 /data/data/org.libsdl.app/lib/libSDL.so
I/DEBUG ( 85): 593c0928 001dc150
I/DEBUG ( 85): 593c092c 00173208
I/DEBUG ( 85): 593c0930 00000000
I/DEBUG ( 85): 593c0934 00000800
I/DEBUG ( 85): 593c0938 001fcbc0
I/DEBUG ( 85): 593c093c aff4633c
I/DEBUG ( 85): 593c0940 09e74000
I/DEBUG ( 85): 593c0944 aff10e48 /system/lib/libc.so
I/DEBUG ( 85): 593c0948 001fcbc0
I/DEBUG ( 85): 593c094c aff4633c
I/DEBUG ( 85): 593c0950 09e74000
I/DEBUG ( 85): 593c0954 aff10e48 /system/lib/libc.so
I/DEBUG ( 85): 593c0958 df002777
I/DEBUG ( 85): 593c095c e3a070ad
I/DEBUG ( 85): #00 593c0960 0013eb80
I/DEBUG ( 85): 593c0964 00000028
I/DEBUG ( 85): 593c0968 aff4683c
I/DEBUG ( 85): 593c096c 00000000
I/DEBUG ( 85): 593c0970 00000000
I/DEBUG ( 85): 593c0974 593c0a40
I/DEBUG ( 85): 593c0978 593c0a40
I/DEBUG ( 85): 593c097c 001dbf50
I/DEBUG ( 85): 593c0980 001dbe88
I/DEBUG ( 85): 593c0984 00000004
I/DEBUG ( 85): 593c0988 00000001
I/DEBUG ( 85): 593c098c 8075ab83 /data/data/org.libsdl.app/lib/libSDL.so
I/DEBUG ( 85): #01 593c0990 001dbf50
I/DEBUG ( 85): 593c0994 8075a05b /data/data/org.libsdl.app/lib/libSDL.so
I/BootReceiver( 155): Copying /data/tombstones/tombstone_00 to DropBox (SYSTEM_TOMBSTONE)
I/ActivityManager( 155): Process org.libsdl.app (pid 2526) has died.
I/WindowManager( 155): WIN DEATH: Window{40daf208 org.libsdl.app/org.libsdl.app.SDLActivity paused=false}
W/WindowManager( 155): Force-removing child win Window{40b6dc58 SurfaceView paused=false} from container Window{40daf208 org.libsdl.app/org.libsdl.app.SDLActivity paused=false}
D/Zygote ( 87): Process 2526 terminated by signal (11)

(3) reading that there might be issues with OGL_ES2, I set changes the
SDL_android_config.h to

#define SDL_VIDEO_RENDER_OGL_ES2 0

That’s old news, the ES2 renderer works fine now.

this builds, but on the Transformer it bombs after loading the data files
(see dump below)
(4) trying the same android-project on Android3.1, gives another coredump
(see below)
(5) hg clone -u SDL-1.2 http://hg.libsdl.org/SDL SDL-1.2
… no sign of any android support

(6) hg clone -u SDL-1.3 http://hg.libsdl.org/SDL SDL-1.3
… no sign of any android support

(7) hg clone http://hg.libsdl.org/SDL
Ah! android-project et al…

followed through the README

No sign of SDL_mixer, or SDL_image so not a great start, also,
“WARNING: This code is under construction, may not build, and is unstable!”

and it’s SDL 2.0 and I don’t even really want to move to SDL 1.3

so abandoned and now hoping someone can help.

SDL2 = SDL 1.3.
You should clone from http://hg.libsdl.org/SDL, follow the
instructions in the README, I would advise not using the prepackaged
android.zip demo as it may be old.
You also need to compile SDL_image, SDL_ttf and any other things you
depend on. If you want to see an example of a working project, you can
check the source code of my engine at ignifuga.org, there’s a complete
android skeleton project in there that you can probably use with few
changes.–
Gabriel.