Environment variables not set for release
When I start my app, it crashes immediately with
Starting beam...
"/data/app/~~FKhNe6zQepp0iAw8dkkm4w==/io.elixirdesktop.example-OyaoOu7v7CwAl0mYQ0MkFQ==/lib/arm64/liberlang.so": ignoring DT_PREINIT_ARRAY in shared library!
{"init terminating in do_boot",{#{'__exception__'=>true,'__struct__'=>'Elixir.ArgumentError',message=><<"could not fetch environment variable \"RELEASE_SYS_CONFIG\" because it is not set">>},[{'Elixir.System','fetch_env!',1,[{file,"lib/system.ex"},{line,698}]},{'Elixir.Config.Provider','resolve_config_path!',1,[{file,"lib/config/provider.ex"},{line,185}]},{'Elixir.Config.Provider',boot,1,[{file, "lib/config/provider.ex"},{line,222}]},{init,eval_script,2,[]},{init,do_boot,3,[]}]}}
This is because in https://github.com/elixir-desktop/android-example-app/blob/d332169bcc968855848313f4bfda07d5e4d15027/app/src/main/cpp/native-lib.cpp#L99 the release is started in an unorthodox way, without running the release script. This means necessary env vars are not set.
I got it fixed with this kludge in that same file:
setenv("RELEASE_SYS_CONFIG", config_path.c_str(), 1);
setenv("RELEASE_ROOT", root_dir.c_str(), 1);
But I'm guessing for full compatibility either the startup should be changed to run the normal startup script (i.e. rel/<app>/bin/<app> start) or every env var from it should be emulated in a similar way as it does. I'm assuming the reason for starting the current way is to deal with Android specific stuff? I couldn't get it to start by calling the release script directly, but I'm really out of my depth in Android stuff.
That's a great addition I would like to add that to the sample. The main driver of the unorthodox startup is iOS which is even more restrictive - so improving the way native-lib.cpp starts a release is probably the safest future approach.