Skip to content
This repository was archived by the owner on Apr 27, 2026. It is now read-only.

Commit 33e10ab

Browse files
committed
Update to OTP-25
1 parent 84d2680 commit 33e10ab

127 files changed

Lines changed: 188 additions & 13776 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
/app/release
44
/local.properties
55
/.idea/caches
6+
/.idea/misc.xml
67
/.idea/libraries
78
/.idea/modules.xml
89
/.idea/workspace.xml

.idea/vcs.xml

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

README.md

Lines changed: 23 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -2,38 +2,38 @@
22

33
This Android Studio project wraps the [Desktop Sample App](https://github.com/elixir-desktop/desktop-example-app) to run on an Android phone.
44

5-
## How to build & run
5+
## Runtime Notes
66

7-
1. Install the beta OTP build *(see known issues)
8-
9-
1. Install [Android Studio](https://developer.android.com/studio) + NDK.
7+
The pre-built Erlang runtime for Android ARM/ARM64/x86 is embedded in this example git repository. These native runtime files include Erlang OTP and the exqlite nif to use SQLite on the mobile. These runtimes are generated using the CI of the [Desktop Runtime](https://github.com/elixir-desktop/runtimes) repository.
108

11-
1. Go to "Files -> New -> Project from Version Control" and enter this URL: https://github.com/elixir-desktop/android-example-app/
9+
Because Erlang OTP has many native hooks for networking and cryptographics the Erlang version used to compile your App must match the pre-built binary release that is embedded. In this example that is Erlang OTP 25.0.4. This sample is shipping with a `.tool-versions` file that `asdf` will automatically use to automate this requirement.
1210

13-
1. Update the `run_mix` to activate the correct Erlang/Elixir version during build.
11+
## How to build & run
1412

15-
1. [Connect your Phone](https://developer.android.com/studio/run/device) to Android Studio
13+
1. Install [Android Studio](https://developer.android.com/studio) + NDK.
14+
1. Install git, npm, asdf
1615

17-
1. Start the App
16+
```
17+
sudo apt install git npm curl
18+
git clone https://github.com/asdf-vm/asdf.git ~/.asdf --branch v0.10.2
19+
echo ". $HOME/.asdf/asdf.sh" >> ~/.bashrc
20+
echo ". $HOME/.asdf/completions/asdf.bash" >> ~/.bashrc
21+
. $HOME/.asdf/asdf.sh
22+
```
1823

19-
## Known todos
24+
1. Install Erlang-OTP (with openssl) in the same version 25.0.4 as the bundled runtime edition:
2025

21-
### Update built-in Runtime
26+
```
27+
asdf install erlang 25.0.4
28+
asdf install elixir 1.13.4-otp-25
29+
```
2230

23-
To have the embedded Erlang match the one you use for compilation you can install
24-
the same version as the embedded:
31+
1. Go to "Files -> New -> Project from Version Control" and enter this URL: https://github.com/elixir-desktop/android-example-app/
2532

26-
```bash
27-
mkdir -p ~/projects/
28-
kerl build git https://github.com/diodechain/otp.git diode/beta 24.beta
29-
kerl install 24.beta ~/projects/24.beta
30-
```
33+
1. Start the App
3134

32-
The current runtime that is precompiled and sits in assets/ folder is based on dev branch of OTP currently under
33-
https://github.com/diodechain/otp/tree/diode/beta
34-
Because the included OTP apps have different versions such as `crypto-5.0.3` you can only compile this project
35-
with the very same OTP version. You can probably build it with `kerl`. But I'll update the runtime to a newer stable
36-
OTP build soon`(tm)` because all neccesary changes have been merged by the Erlang team already.
35+
36+
## Known todos
3737

3838
### Initial Startup could be faster
3939

@@ -45,10 +45,6 @@ This sample only launch the elixir app and shows it in an Android WebView. There
4545

4646
## Other notes
4747

48-
- The current sample is using __Android API 23__ and above
49-
50-
- The Erlang runtime is for ease of use embedded in this example git repository. The native runtimes for Android ARM, ARM64 and X86_64 and the exqlite nif are are generated using the [Desktop Runtime](https://github.com/elixir-desktop/runtimes) repository.
51-
5248
- Android specific settings, icons and metadata are all contained in this Android Studio wrapper project.
5349

5450
- `Bridge.kt` and the native library are doing most of the wrapping of the Elixir runtime.
@@ -62,4 +58,4 @@ This sample only launch the elixir app and shows it in an Android WebView. There
6258

6359
![App](/android_elixir.png?raw=true "Architecture")
6460

65-
The Android App is initializing the Erlang VM and starting it up with a new environment variable `BRIDGE_PORT`. This environment variable is used by the `Bridge` project to connect to a local TCP server _inside the android app_. Through this new TCP communication channel all calls that usually would go to `wxWidgets` are now redirected. The Android side of things implements handling in `Bridge.kt`.
61+
The Android App is initializing the Erlang VM and starting it up with a new environment variable `BRIDGE_PORT`. This environment variable is used by the `Bridge` project to connect to a local TCP server _inside the android app_. Through this new TCP communication channel all calls that usually would go to `wxWidgets` are now redirected. The Android side of things implements handling in `Bridge.kt`.

app/.tool-versions

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
Erlang 25.0.4
2+
erlang 25.0.4
3+
Elixir 1.13.4-otp-25
4+
elixir 1.13.4-otp-25

app/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ android {
88
buildToolsVersion "30.0.3"
99

1010
task buildNum(type: Exec, description: 'Update Elixir App') {
11-
commandLine '../run_mix', 'package.mobile'
11+
commandLine './run_mix', 'package.mobile'
1212
}
1313

1414
tasks.withType(JavaCompile) {

app/libs/erlang.jar

146 KB
Binary file not shown.

app/run_mix

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
#!/bin/bash
2+
set -e
3+
4+
BASE=`pwd`
5+
APP_FILE="$BASE/src/main/assets/app.zip"
6+
export MIX_ENV=prod
7+
export MIX_TARGET=android
8+
9+
if [ ! -d "elixir-app" ]; then
10+
git clone https://github.com/elixir-desktop/desktop-example-app.git elixir-app
11+
fi
12+
13+
# using the right runtime versions
14+
if [ ! -f "elixir-app/.tool-versions" ]; then
15+
cp .tool-versions elixir-app/
16+
fi
17+
18+
cd elixir-app
19+
20+
if [ ! -d "deps/desktop" ]; then
21+
mix local.hex --force
22+
mix local.rebar
23+
mix deps.get
24+
fi
25+
26+
if [ ! -d "assets/node_modules" ]; then
27+
cd assets && npm i && cd ..
28+
fi
29+
30+
if [ -f "$APP_FILE" ]; then
31+
rm "$APP_FILE"
32+
fi
33+
34+
mix assets.deploy && \
35+
mix release --overwrite && \
36+
cd "_build/${MIX_TARGET}_${MIX_ENV}/rel/todo_app" && \
37+
zip -9r "$APP_FILE" lib/ releases/ --exclude "*.so"
38+

app/src/main/AndroidManifest.xml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,9 @@
2525
android:resource="@xml/provider_paths" />
2626
</provider>
2727

28-
<activity android:name="io.elixirdesktop.example.MainActivity">
28+
<activity
29+
android:configChanges="orientation|screenSize|screenLayout|keyboardHidden|density|fontScale|keyboard|layoutDirection|mcc|mnc|navigation|smallestScreenSize|touchscreen|uiMode"
30+
android:name="io.elixirdesktop.example.MainActivity">
2931
<intent-filter>
3032
<action android:name="android.intent.action.MAIN" />
3133
<category android:name="android.intent.category.LAUNCHER" />
618 KB
Binary file not shown.
-462 KB
Binary file not shown.

0 commit comments

Comments
 (0)