SDL2_image Android with png support

My game engine uses SDL2 2.0.3, SDL2_image 2.0.0, and SDL2_mixer 2.0.0. It currently works on Windows x86/x86_64, Linux x86/x86_64, and OS X x86_64. I’m trying to port it to Android. I’ve started with the default android-project included with the source. I followed the instructions, and was able to build everything. To build SDL2_image, I had to follow some instructions I found online, but what I did was disable everything but PNGs in the Android.mk file for SDL2_image, add it to LOCAL_C_INCLUDES, and add it to LOCAL_SHARED_LIBRARIES (both in jni/src/Android.mk) I also uncommented the System.loadLibrary call in the java file. The whole thing builds and links fine. I can build an apk and send it to my phone and run it. However, IMG_Init(IMG_INIT_PNG) fails with the message “PNG images are not supported”. According to my reading online, libpng is built into SDL2_image, so that shouldn’t be the problem, theoretically. Have I missed something obvious? Do I need to build/link/something libpng in some other way to get it to work?

http://comments.gmane.org/gmane.comp.lib.sdl/65956On Fri, Jun 20, 2014 at 12:14 PM, Dark_Oppressor wrote:

My game engine uses SDL2 2.0.3, SDL2_image 2.0.0, and SDL2_mixer 2.0.0.
It currently works on Windows x86/x86_64, Linux x86/x86_64, and OS X
x86_64. I’m trying to port it to Android. I’ve started with the default
android-project included with the source. I followed the instructions, and
was able to build everything. To build SDL2_image, I had to follow some
instructions I found online, but what I did was disable everything but PNGs
in the Android.mk file for SDL2_image, add it to LOCAL_C_INCLUDES, and add
it to LOCAL_SHARED_LIBRARIES (both in jni/src/Android.mk) I also
uncommented the System.loadLibrary call in the java file. The whole thing
builds and links fine. I can build an apk and send it to my phone and run
it. However, IMG_Init(IMG_INIT_PNG) fails with the message “PNG images are
not supported”. According to my reading online, libpng is built into
SDL2_image, so that shouldn’t be the problem, theoretically. Have I missed
something obvious? Do I need to build/link/something libpng in some other
way to get it to work?


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org

I actually already read that earlier tonight while googling. It makes no mention of my problem as far as I can see. Are you saying I should add a link in jni/ to the libpng folder? If so, wouldn’t something else need to be changed too? Would it just be the Android.mk for SDL2_image? That link mentions adding lines to the activity to load more libraries but libpng wasn’t mentioned, and as far as I can tell it is just built into SDL2_image, and there’s no .so.

Juan Manuel Borges Ca??o wrote:> http://comments.gmane.org/gmane.comp.lib.sdl/65956 (http://comments.gmane.org/gmane.comp.lib.sdl/65956)

On Fri, Jun 20, 2014 at 12:14 PM, Dark_Oppressor <DarkOppressor at gmail.com (DarkOppressor at gmail.com)> wrote:

  My game engine uses SDL2 2.0.3, SDL2_image 2.0.0, and SDL2_mixer 2.0.0. It currently works on Windows x86/x86_64, Linux x86/x86_64, and OS X x86_64. I'm trying to port it to Android. I've started with the default android-project included with the source. I followed the instructions, and was able to build everything. To build SDL2_image, I had to follow some instructions I found online, but what I did was disable everything but PNGs in the Android.mk file for SDL2_image, add it to LOCAL_C_INCLUDES, and add it to LOCAL_SHARED_LIBRARIES (both in jni/src/Android.mk) I also uncommented the System.loadLibrary call in the java file. The whole thing builds and links fine. I can build an apk and send it to my phone and run it. However, IMG_Init(IMG_INIT_PNG) fails with the message "PNG images are not supported". According to my reading online, libpng is built into SDL2_image, so that shouldn't be the problem, theoretically. Have I missed something obvious? Do I need to build/link/something libpng in some other way to get it to work?

SDL mailing list
SDL at lists.libsdl.org (SDL at lists.libsdl.org)
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org (http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org)

I have no issue with the default setup, .S to .C and the links in jni/src.
Or you call IMG_Init before SDL_Init or you perhaps messed the Android.mk
edit, so my advice is: try again but don’t modify SDL_Image .mk other than
.tS to .C. Experience from that post is that, thay way, works. PNG et all.

LOL I read your post and I was thinking “Pft I have not touched that freaking Android.mk file for SDL2_image, that is not the problem!” Um, but then I checked it against a freshly downloaded one, and I had added " /" (a space and a slash) at the end of the LOCAL_C_INCLUDES line for the libpng stuff. So I removed that, and what do you know, it works now.

So in the end:
I actually didn’t change anything in the Android.mk except for setting the non-png image types to false. I also didn’t need to symlink the pibpng directory anywhere, and I didn’t have to mess with the activity anymore either. So yay! Thanks for the help!