DioxusLabs / DioxusLabs/dioxus
android platform fails to bundle on nixos
- Dominant language
- Rust
- Stars
- 39.1k
- Forks
- 1.9k
- Avg merge
- 4d 10h
- Merged PRs (30d)
- 4
Description
**Problem**
`dx build --platform android` compiles but does not bundle.
```
59.314s INFO Bundling app...
59.323s ERROR err=Other(Failed to write main executable
Caused by:
0: I/O Error: No such file or directory (os error 2)
1: No such file or directory (os error 2))
59.326s ERROR err=Other(Failed to write main executable
Caused by:
0: I/O Error: No such file or directory (os error 2)
1: No such file or directory (os error 2))
```
**Steps To Reproduce**
`Cargo.toml:`
```toml
[package]
name = "my_app"
version = "0.1.0"
edition = "2021"
[dependencies]
dioxus = { version = "0.6.2", features = ["desktop", "mobile", "macro"] }
[profile]
[profile.wasm-dev]
inherits = "dev"
opt-level = 1
[profile.server-dev]
inherits = "dev"
[profile.android-dev]
inherits = "dev"
```
`src/main.rs:`
```rust
use dioxus::prelude::*;
fn minimal() -> Element {
rsx!{ "hello world" }
}
fn main()
{
dioxus::launch(minimal);
}
```
`shell.nix:`
```nix
{
# pkgs ? import { },
}:
let
pkgs = import (fetchTarball("channel:nixpkgs-unstable")) {};
overrides = (builtins.fromTOML (builtins.readFile ./rust-toolchain.toml));
buildToolsVersion = "30.0.3";
androidComposition = pkgs.androidenv.composeAndroidPackages {
cmdLineToolsVersion = "8.0";
toolsVersion = "26.1.1";
platformToolsVersion = "35.0.2";
buildToolsVersions = [ buildToolsVersion ];
includeEmulator = true;
emulatorVersion = "35.4.6";
platformVersions = [ "28" "29" "30" ];
includeSources = false;
includeSystemImages = false;
systemImageTypes = [ "google_apis_playstore" ];
abiVersions = [ "armeabi-v7a" "arm64-v8a" ];
cmakeVersions = [ "3.10.2" ];
includeNDK = true;
ndkVersions = ["22.0.7026061"];
useGoogleAPIs = false;
useGoogleTVAddOns = false;
includeExtras = [
"extras;google;gcm"
];
};
ANDROID_HOME = "${androidComposition.androidsdk}/libexec/android-sdk";
in
pkgs.callPackage (
{
atkmm,
cairo,
gcc,
gdk-pixbuf,
glib,
gtk3,
mkShell,
openssl,
pango,
pkg-config,
rustup,
rustPlatform,
stdenv,
webkitgtk_4_1, # for javascriptcoregtk-rs-sys
xdotool, # for libxdo
}:
mkShell {
strictDeps = true;
nativeBuildInputs = [
gcc
openssl
pkg-config
rustup
rustPlatform.bindgenHook
];
buildInputs = [
atkmm
cairo
gdk-pixbuf
glib
gtk3
pango
webkitgtk_4_1
xdotool
];
GDK_BACKEND = "x11"; # NVIDIA might disagree otherwise.
PKG_CONFIG_PATH = "${pkgs.openssl.dev}/lib/pkgconfig";
RUSTC_VERSION = overrides.toolchain.channel;
WEBKIT_DISABLE_DMABUF_RENDERER = 1; # Again NVIDIA things.
ANDROID_HOME = ANDROID_HOME;
ANDROID_NDK_ROOT = "${ANDROID_HOME}/ndk-bundle";
NDK_HOME = "${ANDROID_HOME}/ndk/22.0.7026061";
# Use the same buildToolsVersion here
GRADLE_OPTS = "-Dorg.gradle.project.android.aapt2FromMavenOverride=${ANDROID_HOME}/build-tools/${buildToolsVersion}/aapt2";
# https://github.com/rust-lang/rust-bindgen#environment-variables
shellHook = ''
export PATH="''${CARGO_HOME:-~/.cargo}/bin":"$PATH"
export PATH="''${RUSTUP_HOME:-~/.rustup}/toolchains/$RUSTC_VERSION-${stdenv.hostPlatform.rust.rustcTarget}/bin":"$PATH"
'';
}
) { }
```
Note here that I did not set `JAVA_HOME`. I'm not sure what to set it to and I do not know whether that is the source of my trouble.
This `shell.nix` has seen various iterations. One where I use https://tadfisher.github.io/android-nixpkgs instead of `pkgs.androidenv` and one where I tried to just use android-studio, but could not get dioxus to recognize the project (but that might just be a me-problem).
Finally, the commands I then run is
```sh
nix-shell
rustup target add aarch64-linux-android armv7-linux-androideabi i686-linux-android x86_64-linux-android
rustup default nightly
cargo install dioxus-cli
dx build --platform android
```
**Expected behavior**
No failure, but a bundled `.apk` (I think, I've never gotten it to bundle)
**Environment:**
- Dioxus version: 0.6.2
- Rust version: 1.87.0-nightly
- OS info: NixOS 24.11 (shell.nix was used for 24.11 and unstable)
- App platform: mobile
- dioxus-cli version: 0.6.3 (crates) and main.
**Questionnaire**
I'm interested in fixing this myself but don't know where to start.
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.