Ada-based applications in Android?

I have been struggling to make my Ada program run on Android (through a Java native interface), with so far no results. As I understand it, the generic Linux GCC compiler will not make the job, because even if it targets the right architecture (arm64), the compiler toolchain needs to be built using Android “binutils”. Is it like that (or even more complex than that)?
In any case, frustrated by the fact that my SAL generated with gprbuild and GCC will refuse to work (at least with the FSF compiler), I posted my issue on Stack Overflow, and somebody threw the idea of using LLVM instead. So I was wondering if the Gnat LLVM project could help me here.
I started reading about LLVM, and I find it a bit hard to grasp. My current understanding is that I could use it to compile Ada into IR code, that would be then compiled into machine code for an specific architecture, without requiring the installation of a particular cross compiler. Is that right?
Is it theoretically feasible to generate a SAL with a Java interface for Android using this toolchain? And if so, how?
Otherwise, could somebody expose the purpose and/or usages of Gnat LLVM?

Before you react, please know that my understanding of compilers is very limited…
In case you are curious about what I am doing, my project is open source, you can take a look at it here:

Nice looking project. I hope you find a solution to getting it to work on Android.

1 Like

Thanks. Helping hands are welcome :slight_smile:
At the moment I am very pessimistic about getting it to work in Android… This is exceeding my understanding, and because I have little time to dedicate to all this, I can’t make a decent progress in the development of the program and the compilation at the same time… So if I find the time at night after the kids are in bed; I chose for the former…
And so you see why people choose for other programming languages, like Java (which is sad, because Ada really is superior in so many ways). But it is not really my business to get into the compiler. I do this for the pleasure, so I want to do what I do best.

Go used to use the I think it is called the android ndk but it was still reasonably painful. I was working from a Rust blog.

I wish to do something similar eventually and will be looking into Adas C interfacing to Androids FFI support (in my case for Flutter). I have a hunch it will be easier than with Go but proof is in the pudding.

Android native supports C directly so I guess it should be more straight forward than Dart:FFI just using Adas C Interfacing.

The following link on C interfacing might be useful.

The issue I encountered was not with the Java native interface, since I managed to make that work on the Linux PC. I think my problem is to get the library compiled for Android using the FSF compiler.
Lete know if you manage to succeed on that…

So from what I have seen you usually build an .so and then have to put it in a certain folder in your project for Android Studio to pick up. I think that there may be some boiler plate too. I don’t know anything about java so perhaps this all irrelevant. Though Adas C interfacing support is excellent and so certainly an option.

Yes, well, what I have tried was using gprbuild on a ARM board to try to get a standalone library. But the Android app would crash when trying to retrieve the library. The dependencies of the library where very basic (libc and another Linux kernel interfacing library I think), libgnat was not one of them. So I truly don’t know where the problem was. I might try another attempt in the future.