dioxus icon indicating copy to clipboard operation
dioxus copied to clipboard

"mobile" feature is not found in latest dioxus and causing failure of mobile build

Open HarrisonOwl opened this issue 3 years ago • 2 comments

Problem I'm trying to build a mobile app with cargo-mobile and dioxus-mobile with the guide on dioxuslab. But it fails to build and gives error that "mobile" feature not exist in latest dioxus.

My Cargo.toml:

[package]
name = "rust-mobile"
version = "0.1.0"
authors = ["HarrisonOwl <[email protected]>"]
edition = "2018"

[lib]
crate-type = ["staticlib", "cdylib", "rlib"]

[[bin]]
name = "rust-mobile-desktop"
path = "gen/bin/desktop.rs"

[dependencies]
mobile-entry-point = "0.1.0"
winit = "0.23.0"
dioxus = { version = "*", features = ["mobile"] }

[target.'cfg(target_os = "android")'.dependencies]
android_logger = "0.9.0"
log = "0.4.11"
ndk-glue = "0.2.1"

[target.'cfg(not(target_os = "android"))'.dependencies]
simple_logger = "1.11.0"

Does dioxus removed mobile support?

Steps To Reproduce

Steps to reproduce the behavior:

  • Follow the guide on dioxuslab and create dioxus-mobile project.
  • Edit source code and Cargo.toml.
  • Build project with cargo android run and you will see the error.

Expected behavior

  • Get the proper crate and success to build apk for android device.

Screenshots When I try to build app with 'cargo android run', it gives error:

error: failed to select a version for `dioxus`.
    ... required by package `rust-mobile v0.1.0 (/home/(username)/rust-mobile)`
versions that meet the requirements `*` are: 0.2.4, 0.2.3, 0.2.2, 0.2.1, 0.2.0, 0.1.8, 0.1.7, 0.1.6, 0.1.5, 0.1.4, 0.1.3, 0.1.0

the package `rust-mobile` depends on `dioxus`, with features: `mobile` but `dioxus` does not have these features.

And when I try to add dependency with cargo add, it also gives warning:

    Updating 'https://github.com/rust-lang/crates.io-index' index
    Warning: Unrecognized features: ["mobile"]
      Adding dioxus * to dependencies.
             Features:
             + dioxus-core-macro
             + dioxus-hooks
             + dioxus-html
             + hooks
             + html
             + macro
             + mobile
             - ayatana
             - desktop
             - dioxus-desktop
             - dioxus-interpreter-js
             - dioxus-liveview
             - dioxus-native-core
             - dioxus-native-core-macro
             - dioxus-router
             - dioxus-ssr
             - dioxus-tui
             - dioxus-web
             - fermi
             - liveview
             - native-core
             - router
             - ssr
             - tui
             - web

Environment:

  • Dioxus version: 0.2.4
  • Rust version: rustc 1.61.0 (fe5b13d68 2022-05-18)
  • OS info: Ubuntu 22.04
  • App platform: mobile

Questionnaire

  • [x] I'm interested in fixing this myself but don't know where to start
  • [ ] I would like to fix and I have a solution
  • [ ] I don't have time to fix this right now, but maybe later

HarrisonOwl avatar May 28 '22 12:05 HarrisonOwl

Hi!

Does dioxus removed mobile support?

I don't know the reasoning behind this change, but looks like mobile support was indeed (temporarily?) removed in e7505188d6696eb56751ed05cbf1b92f20a6e364, for v0.2, by commenting out the dioxus-mobile dependency. Perhaps the crate is outdated.

I'm interested in fixing this myself but don't know where to start

I'm not sure either. However, you could try cloning the repo and adding the dependency back in. Perhaps there will be error messages which might guide you towards making it work again.

rMazeiks avatar May 29 '22 11:05 rMazeiks

This will be fixed in #387

Sorry about this!

The mobile renderer is currently the same as the desktop renderer - there are no differences between the two (currently), hence its temporary removal in the 0.2.0 release.

However after #387 it will be part of its own crate and not a feature, meaning we can increment its minor versions and re-release it.

jkelleyrtp avatar Jul 07 '22 05:07 jkelleyrtp

Hi, just checking in to say that web and desktop works perfectly, so having mobile support again would be awesome! This might be off-topic, but if I tried cargo android check it fails because wry was resolved to a version too old (0.13.1), way before Android support was added. cargo apple check seems to encounter the same problem as well.

$ cargo add [email protected]
error: failed to select a version for `webkit2gtk-sys`.
    ... required by package `wry v0.13.1`
    ... which satisfies dependency `wry = "^0.13.1"` of package `dioxus-desktop v0.2.3`
    ... which satisfies dependency `dioxus-desktop = "^0.2.3"` of package `dioxus v0.2.4`
    ... which satisfies dependency `dioxus = "^0.2.4"` of package `todo-dioxus v0.1.0 (/Users/vdinh/dev/todo-dioxus)`
versions that meet the requirements `^0.17` are: 0.17.0

the package `webkit2gtk-sys` links to the native library `web_kit2`, but it conflicts with a previous package which links to `web_kit2` as well:
package `webkit2gtk-sys v0.18.0`
    ... which satisfies dependency `ffi = "^0.18"` of package `webkit2gtk v0.18.2`
    ... which satisfies dependency `webkit2gtk = "^0.18.2"` of package `wry v0.23.4`
    ... which satisfies dependency `wry = "^0.23.4"` of package `todo-dioxus v0.1.0 (/Users/vdinh/dev/todo-dioxus)`
Only one package in the dependency graph may specify the same links value. This helps ensure that only one copy of a native library is linked in the final binary. Try to adjust your dependencies so that only one package uses the links ='webkit2gtk-sys' value. For more information, see https://doc.rust-lang.org/cargo/reference/resolver.html#links.

Desdaemon avatar Dec 19 '22 07:12 Desdaemon

Wry is now updated to 0.23.4!

jkelleyrtp avatar Dec 30 '22 08:12 jkelleyrtp