Erlang on Android

Dominic Letz <[email protected]>
Newsgroups gmane.comp.lang.erlang.general
Message-ID <CACbRgNKEAXwieBSx7zZ0Nyu+uk_ca=MvFAZog_5JBfHnh6B_BA@mail.gmail.com>
Hey there,

just wanted to share another approach to running Erlang within an Android
application that might be useful for others. In the quest to bring our
companies app to Android we decided to use beam.smp binary as a shared
library because on Linux (and Android for that matter) ELF binaries are
just the same as shared libraries.

So with only updated environment flags for compilation and linking, we
compiled OTP and then renamed beam.smp into liberlang.so to use within our
app

Additional OTP compilation flags:
CFLAGS="-Os -fPIC" CXXFLAGS="-Os -fPIC" LDFLAGS="-z global"
for reproducibility the runtimes are generated in a GitHub project from
Dockerfiles using GitHub CI:
https://github.com/elixir-desktop/runtimes

Now our app is Elixir based and uses Elixir Phoenix LiveView web framework
to generate a UI that the Andoird app is then presenting in a local
WebView. But the same approach would work of course with a pure
Erlang/cowboy setup.
Full Elixir Android app source code, with Erlang runtimes ready to build:
https://github.com/elixir-desktop/android-example-app

I also would like to mention Jérôme de Bretagne who worked on making Erlang
run on Android 10 and whose insights there were extremely helpful.

One issue that might affect Android compatibility is the dependency on the
two external binaries erl_child_setup and inet_gethost. With Android 10
Google has made it significantly harder to ship executable binaries with
your app. There is the workaround that I've found in Jérôme's repository to
bundle erl_child_setup as "lib__erl_child_setup.so" to trick the Android
application bundler into accepting the file as a library into the package
and then creating a symlink that is named erl_child_setup after
installation to make it executable again.

So this brings me to my question #1. Is there a way to remove the
dependency on these external binaries of erl_child_setup and inet_gethost
currently that anyone is aware of? Or will this require an OTP code change?

Question #2: Has anyone tried bundling Erlang into iPad/iPhone apps with
any pointers to repos?

Cheers
-- 
// Dominic Letz | CTO
+49 163 9198 211 (.de)
[email protected]

DIODE
diode.io
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.