Hello world on Android

So I’ve been trying to get a hello world working on Android, but with no real luck yet - currently getting a blank exception in logcat.
I’ve verified that that particular exception text is written from hlc_main.c 's if( isExc ) block. I’ve also verified that Hashlink code is running and the heapsapp code is running (I’ve added log entries to each, and they’re both in logcat).

I suspect it has to do with SDL - SDL_InitSubSystem is being called, but it’s returning -1 because if (!SDL_MainIsReady) is apparently true. Which I take to mean that a function called SDL_MainIsRead doesn’t exist.

There’s a handy error message there that I see in the code: SDL_SetError("Application didn't initialize properly, did you include SDL_main.h in the file containing your main() function?");

Which… I feel like that should help me more than it does. I must be doing something very obviously wrong, but at this point I’m like 4 days deep and I have no idea what.

I notice now that @ncannasse said here that the repo I’ve been basing it off of doesn’t start the SDL window yet, but that was like three years ago, so…I’m not sure the current status.

Any ideas?

From what I remember, when you have your main entry point you need to #include <SDL_main.h> so it will somewhat replace your main() with its own main entry point and do some platform specific setup.
This should be done here:

Awesome - thank you! I got a hello world working on Android, and wrote a bit about it here: https://gigglingcorpse.com/2021/11/22/hello-world-heaps-on-android.

I cleaned up my Android Studio project and made it a repo on github (with some info in the readmes as well), in case that’s useful to anyone: https://github.com/altef/heaps-android

2 Likes