elixir-desktop / android-example-app

Android Studio project wrapper around the Elixir TodoApp Desktop app to run on Android including the Erlang runtime
MIT License
102 stars 10 forks source link

No driver found for wx #7

Open Nicd opened 2 years ago

Nicd commented 2 years ago

My app immediately crashes on startup with

20:39:12.827 [error] ERROR: Could not find 'wxe_driver.so' in: /data/user/0/io.elixirdesktop.example/files/app/lib/wx-2.2/priv
20:39:12.834 [notice] Application desktop exited: Desktop.start(:normal, []) returned an error: shutdown: failed to start child: Desktop.Env
        ** (EXIT) an exception was raised:
            ** (ErlangError) Erlang error: {:load_driver, 'No driver found'}
                (wx 2.2) wxe_server.erl:65: :wxe_server.start/1
                (wx 2.2) wx.erl:115: :wx.new/1
                (desktop 1.4.1) lib/desktop/env.ex:28: Desktop.Env.init/1
                (stdlib 4.0.1) gen_server.erl:848: :gen_server.init_it/2
                (stdlib 4.0.1) gen_server.erl:811: :gen_server.init_it/6
                (stdlib 4.0.1) proc_lib.erl:240: :proc_lib.init_p_do_apply/3

Everything builds correctly though.

Nicd commented 2 years ago

This was due to the run_mix script stripping all *.so files from the built app.zip. When I include the library, I'm getting

20:52:44.691 [error] WX ERROR: Could not load library: :load_failed
    Failed to load NIF library /data/user/0/io.elixirdesktop.example/files/app/lib/wx-2.2/priv/wxe_driver: 'dlopen failed: "/data/data/io.elixirdesktop.example/files/app/lib/wx-2.2/priv/wxe_driver.so" has bad ELF magic: cffaedfe'

so I'm guessing there was a reason for the stripping.

dominicletz commented 2 years ago

There seems to be something wrong with how the release is built. wxWidgets WebView is not available on the phones and thus the sample app is packaging a drop-in-replacement package "bridge" that is using the phones native webview. Try to replace :wx with bridge in your release build, and then it should work.

dominicletz commented 2 years ago

This is the relevant part in the desktop library: https://github.com/elixir-desktop/desktop/blob/dc1575c1963950ff18b2682a3fdb1887ac3a9ffa/mix.exs#L87

Nicd commented 2 years ago

Thanks, that does it! I guess it should be added to instructions somewhere. I can make a PR later, I'm now trying to get this to work.

Btw is there a chat avenue for this library? It would be possibly faster / lower friction than talking in the issues. :) If you use Discord, we could make a separate #elixir-desktop channel on the Elixir server.

dominicletz commented 2 years ago

It's the #desktop channel on the Elixir slack https://join.slack.com/t/elixir-lang/shared_invite/zt-1f13hz7mb-N4KGjF523ONLCcHfb8jYgA

Nicd commented 2 years ago

I guess I need to rejoin Slack then. :)

I have just gotten the app to run for the first time! This is glorious! Thanks so much. <3