This is a personal experiment to get a Odin project running on Android.
Note that I have only tested and run this on Linux. It relies on a Makefile and assume a unix environment.
Caution
The PC version is likely not going to run and I might remove it later to simplify the example.
It should work just fine on MacOS and Windows as long as you setup Android Studio and you either have GNU Make or you translate to a similar script.
Note
It should be possible to not use Android Studio at all, but it would complicate things a bit.
- Odin installed
- Android Studio installed
- Android NDK installed
ANDROID_NDK_HOMEandANDROID_HOMEenvironment variables set
For example, this is how they look like on my machine:
export ANDROID_HOME=$HOME/Android/Sdk
export ANDROID_NDK_HOME=$ANDROID_HOME/ndk/29.0.13846066The default target is android, so you can simply run: make.
After compilation, you should have a directory out/AndroidProject.
Open this in Android Studio as a project and simply debug from there.
I have not yet managed to get breakpoints to work nor to have the debugger break on the source file on a crash.
For now I had to resort to printf debugging.
Any suggestion on how to get this working is welcome.
It should be relatively straightforward to use this as a starting point for your own android project in Odin.
You'll need my_vendor and android_files.
my_vendorcontains bindings for android APIs. Note that these are very much incomplete and you WILL need to add stuff to it;android_filescontains necessary android files likeAndroidManifest.xmlandbuild.gradle. Change them to match your project.
You'll also need a makefile or a build script. You can take a look at Makefile for the command line options you'll need.
Finally, you can create your own entry point. Check android_main in src/main.odin for an example.
Note
You should also add icon and resources to your project, but that's left as an exercise to the reader.
As and if I find the time, I'll like to clean up the vendor files and include more of the android API.
If you have done it and you feel like sharing, please open a PR.
All the code in the project is licensed under the Boost Software License 1.0.
See LICENSE for details.

