<div dir="ltr"><div>Hey there,</div><div><br></div><div>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.<br><br></div><div>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<br><br>Additional OTP compilation flags:<br>CFLAGS="-Os -fPIC" CXXFLAGS="-Os -fPIC" LDFLAGS="-z global"</div><div>for reproducibility the runtimes are generated in a GitHub project from Dockerfiles using GitHub CI: <br><div><a href="https://github.com/elixir-desktop/runtimes">https://github.com/elixir-desktop/runtimes</a></div></div><div><br></div><div>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.<br>Full Elixir Android app source code, with Erlang runtimes ready to build: <a href="https://github.com/elixir-desktop/android-example-app">https://github.com/elixir-desktop/android-example-app</a><br><br>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. <br><br></div>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.<br><div><div><br></div><div>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?<br></div><div><br></div><div>Question #2: Has anyone tried bundling Erlang into iPad/iPhone apps with any pointers to repos?<br></div><div><br>Cheers<br>-- <br><div dir="ltr" class="gmail_signature" data-smartmail="gmail_signature"><div dir="ltr"><div><div dir="ltr"><div>// Dominic Letz | CTO<br></div>+49 163 9198 211 (.de)<br><div><a href="mailto:dominic@diode.io" target="_blank">dominic@diode.io</a></div><div><br></div><div>DIODE<br></div><div><a href="http://diode.io" target="_blank">diode.io</a><br></div></div></div></div></div></div></div></div>