Hey there. I'm throwing together a small Android project and have not been able to procure image files from within my compiled APK. Thankfully, I saw that the wiki had some Android-specific code that fit would the bill: al_android_set_apk_file_interface.
I thought all would be well if I included the appropriate file and called the function, but my compiler thought otherwise.
The above, when compiled with g++ on Ubuntu 13.04 (using Allegro 5.1.8), returned "undefined reference to `al_android_set_apk_file_interface'". It acknowledges allegro_android.h's existence, but not the function's purpose.
As you can see, the function exists but lacks a code body. My guess is that it is to be used as an include elsewhere. So then, what should I do to get this function working properly?
I would greatly appreciate your feedback and/or suggestions. Thank you.
Edit (13.09.06 at 21:39 PST)
Let's forget g++ for the time being. The code compiled without issue for Android. Here's my new code:
Still, it can't locate the image file. Any ideas?
It doesn't compile with g++ because it's Android code; you need to use the Android compiler, which you've done now. Why are you using words like procure. Anyway, show more code or debug with ALLEGRO_DEBUG("Some printf style messages\n"); after putting "ALLEGRO_DEBUG_CHANNEL("MyAppName")" at the top of your file after including allegro5.h. Then use adb logcat to view the messages.
Hey Trent. Thanks for the reply.
Yeah, I already figured that one out. And you're right about "procure"; "load" would have been better. Now, how might I include this in my code if I also wanted to compile for Linux?
I'm going to try out the Android example first. I already compiled and installed it on my OUYA with ease, but I have no way of seeing the debug messages yet. Running adb devices doesn't show my OUYA, so I don't know what's the matter there. Some say you need the Google USB Driver installed from the Android SDK Manager, but I am on Ubuntu 13.04 and those drivers aren't Linux compatible.
When building Monster RPG 2 for OUYA, how did you do it? Did you use adb wirelessly or connect your machine to OUYA via USB cable? Also, which OS did you use to do so?
I may have to go out and purchase an appropriate cable soon to pull this off. What do you suggest?
#ifdef ALLEGRO_ANDROID // android code here #else // other code here #endif
I use a USB cable since the OUYA is right on my desk.
Ha, how simple of a solution. Thanks, Trent.
Okay, I'll have to buy a cable then. What OS did you port for OUYA on? Just curious.
Windows 7.
Oh, all right. I had some worries about compatibility with Linux, but good news: I'm now connected to my OUYA via USB cable! 
Okay. Here's what the example debug message says about alexlogo.png:
I/allegro ( 1161): bitmap W 1176: bitmap_io.c:243 al_load_bitmap_flags [ 0.07439] No handler for bitmap extensions .png - therefore not trying to load alexlogo.png.
I/allegro ( 1161): main D 1176: test.c:88 main [ 0.07441] failed to load alexlogo.png
Fairly self-explanatory; it doesn't have libpng, which I find to be weird. So now we know that is the issue. Does this mean I'll have to compile libpng for Android alongside the Android example: main.c?
Edit (13.09.08 at 21:38 PST)
I downloaded and built libpng for Android, which resulted in a libpng.a file. I threw this file into $HOME/android-toolchain/sysroot/usr/lib and include. I then recompiled the example project to and installed it on my OUYA. The log reveals that it still can not load the png file though; same message as above. What would you suggest I do?
Rebuilds Allegro now that you have libpng installed. Link to libpng in your Android project.
I will try that, but first: how come it will load PNG files if executed from Ubuntu, but not from OUYA? I thought libpng was built alongside Allegro by default (thus I said "it doesn't have libpng, which I find to be weird."). Was I incorrect here?
Now then, in order to pull this off, all I would need to do now is build Allegro normally...
Then build for Android thereafter?
Does that look about right?
No - libpng comes separately, but is natively implemented on some platforms, but not Android apparently or at least not the OUYA. But if you delete CMakeCache.txt and rerun cmake it should find the installed libpng and install it into allegro's image addon.
Aah, okay. That makes sense. I have installed libpng-dev and zlib1g-dev. Will these suffice for libpng support once I build Allegro again?
only if you built them for android.
Check it out. I stumbled across this link for libpng for Android. I went into its folder and ran the following:
I then added LOCAL_LDLIBS += -lpng to Application.mk. I threw it onto OUYA and ran adb logcat, but it still returns the same error. I'll keep looking into this.
Please, for God's sake try to figure out some of these minor snags for yourself. Don't come back until you've figured it out. Learn to learn.
try to figure out some of these minor snags for yourself. Don't come back until you've figured it out. Learn to learn.
Googling is OK, though. Indeed, it's encouraged.
Please, for God's sake try to figure out some of these minor snags for yourself. Don't come back until you've figured it out. Learn to learn.
Please accept my sincere apology for my obtuse nature. It has been this year alone in which I've made the switch to UNIX-like systems and have made an effort to learn C++ and many other things. I am fairly new to these technologies and to Android. I have learned many things already on my own. I ask for assistance here specifically because I couldn't find sufficient information elsewhere.
Googling is OK, though. Indeed, it's encouraged.
I perform search queries quite often, actually. The primary reason I ask here is because some of the users here are especially knowledgeable when it comes to Allegro on Android devices.
Anyway, I tried a bitmap and it worked alright. Actually, the bitmap file was significantly smaller than the png one. Using al_convert_mask_to_alpha() on an 8x9 bitmap didn't work out so well on OUYA (it removed the entire image instead of the magic pink color), so that may just be a bug. It worked on 16x18 bitmaps though.I am going to opt for bmp files for the time being.
I'm going to set this as "resolved" soon enough. Feel free to add onto this until then.