Erlang on Android
Fri Sep 17 12:52:09 CEST 2021
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
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:
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
Full Elixir Android app source code, with Erlang runtimes ready to build:
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?
// Dominic Letz | CTO
+49 163 9198 211 (.de)
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the erlang-questions