Make it build for Android

This commit is contained in:
2026-01-03 21:04:10 +01:00
parent 894f5c5e20
commit 7ce7762a94
6 changed files with 144 additions and 10 deletions
Generated
+102 -9
View File
@@ -70,6 +70,27 @@ version = "0.2.21"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "683d7910e743518b0e34f1186f92494becacb047c7b6bf616c96772180fef923"
[[package]]
name = "android-activity"
version = "0.5.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ee91c0c2905bae44f84bfa4e044536541df26b7703fd0888deeb9060fcc44289"
dependencies = [
"android-properties",
"bitflags 2.10.0",
"cc",
"cesu8",
"jni",
"jni-sys",
"libc",
"log",
"ndk 0.8.0",
"ndk-context",
"ndk-sys 0.5.0+25.2.9519653",
"num_enum",
"thiserror 1.0.69",
]
[[package]]
name = "android-activity"
version = "0.6.0"
@@ -84,13 +105,22 @@ dependencies = [
"jni-sys",
"libc",
"log",
"ndk",
"ndk 0.9.0",
"ndk-context",
"ndk-sys",
"ndk-sys 0.6.0+11769913",
"num_enum",
"thiserror 1.0.69",
]
[[package]]
name = "android-build"
version = "0.1.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8cac4c64175d504608cf239756339c07f6384a476f97f20a7043f92920b0b8fd"
dependencies = [
"windows-sys 0.52.0",
]
[[package]]
name = "android-properties"
version = "0.2.2"
@@ -667,7 +697,7 @@ checksum = "0b023947811758c97c59bf9d1c188fd619ad4718dcaa767947df1cadb14f39f4"
dependencies = [
"glob",
"libc",
"libloading",
"libloading 0.8.9",
]
[[package]]
@@ -1020,7 +1050,7 @@ version = "0.5.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "330c60081dcc4c72131f8eb70510f1ac07223e5d4163db481a04a0befcffa412"
dependencies = [
"libloading",
"libloading 0.8.9",
]
[[package]]
@@ -1652,7 +1682,7 @@ dependencies = [
"dispatch2",
"glutin_egl_sys",
"glutin_wgl_sys",
"libloading",
"libloading 0.8.9",
"objc2 0.6.3",
"objc2-app-kit 0.3.2",
"objc2-core-foundation",
@@ -1938,6 +1968,22 @@ dependencies = [
"tracing",
]
[[package]]
name = "i-slint-backend-android-activity"
version = "1.14.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "38c42a78b1ace78c7fa4ba42de61ba85799342c0b8c62adca33f3132dab427c6"
dependencies = [
"android-activity 0.5.2",
"android-activity 0.6.0",
"android-build",
"i-slint-core",
"i-slint-renderer-skia",
"jni",
"ndk 0.9.0",
"raw-window-handle",
]
[[package]]
name = "i-slint-backend-linuxkms"
version = "1.14.1"
@@ -1977,6 +2023,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e138660c634d6bbdf98bb2d0cfa487cda28e032e133a2a2c974f1cc494198765"
dependencies = [
"cfg-if",
"i-slint-backend-android-activity",
"i-slint-backend-linuxkms",
"i-slint-backend-qt",
"i-slint-backend-winit",
@@ -2374,6 +2421,7 @@ dependencies = [
"tokio",
"wasm-bindgen",
"wasm-bindgen-futures",
"web-sys",
"xdg",
]
@@ -2522,6 +2570,15 @@ version = "1.0.15"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4a5f13b858c8d314ee3e8f639011f7ccefe71f97f96e50151fb991f267928e2c"
[[package]]
name = "java-locator"
version = "0.1.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "09c46c1fe465c59b1474e665e85e1256c3893dd00927b8d55f63b09044c1e64f"
dependencies = [
"glob",
]
[[package]]
name = "jni"
version = "0.21.1"
@@ -2531,7 +2588,9 @@ dependencies = [
"cesu8",
"cfg-if",
"combine",
"java-locator",
"jni-sys",
"libloading 0.7.4",
"log",
"thiserror 1.0.69",
"walkdir",
@@ -2651,6 +2710,16 @@ dependencies = [
"cc",
]
[[package]]
name = "libloading"
version = "0.7.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b67380fd3b2fbe7527a606e18729d21c6f3951633d0500574c4dc22d2d638b9f"
dependencies = [
"cfg-if",
"winapi",
]
[[package]]
name = "libloading"
version = "0.8.9"
@@ -2953,6 +3022,20 @@ dependencies = [
"version_check",
]
[[package]]
name = "ndk"
version = "0.8.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2076a31b7010b17a38c01907c45b945e8f11495ee4dd588309718901b1f7a5b7"
dependencies = [
"bitflags 2.10.0",
"jni-sys",
"log",
"ndk-sys 0.5.0+25.2.9519653",
"num_enum",
"thiserror 1.0.69",
]
[[package]]
name = "ndk"
version = "0.9.0"
@@ -2962,7 +3045,7 @@ dependencies = [
"bitflags 2.10.0",
"jni-sys",
"log",
"ndk-sys",
"ndk-sys 0.6.0+11769913",
"num_enum",
"raw-window-handle",
"thiserror 1.0.69",
@@ -2974,6 +3057,15 @@ version = "0.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "27b02d87554356db9e9a873add8782d4ea6e3e58ea071a9adb9a2e8ddb884a8b"
[[package]]
name = "ndk-sys"
version = "0.5.0+25.2.9519653"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8c196769dd60fd4f363e11d948139556a344e79d451aeb2fa2fd040738ef7691"
dependencies = [
"jni-sys",
]
[[package]]
name = "ndk-sys"
version = "0.6.0+11769913"
@@ -4695,6 +4787,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9c35c4bdca2c42c69b21ceb416aa4ba76c3f54df30e9ce85dcad0742229422a6"
dependencies = [
"const-field-offset",
"i-slint-backend-android-activity",
"i-slint-backend-selector",
"i-slint-core",
"i-slint-core-macros",
@@ -4883,7 +4976,7 @@ dependencies = [
"fastrand",
"js-sys",
"memmap2",
"ndk",
"ndk 0.9.0",
"objc2 0.6.3",
"objc2-core-foundation",
"objc2-core-graphics",
@@ -6544,7 +6637,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c66d4b9ed69c4009f6321f762d6e61ad8a2389cd431b97cb1e146812e9e6c732"
dependencies = [
"ahash",
"android-activity",
"android-activity 0.6.0",
"atomic-waker",
"bitflags 2.10.0",
"block2 0.5.1",
@@ -6558,7 +6651,7 @@ dependencies = [
"js-sys",
"libc",
"memmap2",
"ndk",
"ndk 0.9.0",
"objc2 0.5.2",
"objc2-app-kit 0.2.2",
"objc2-foundation 0.2.2",
+28 -1
View File
@@ -19,14 +19,41 @@ anyhow = "1.0.100"
tokio = { version = "1.48.0", default-features = false, features = ["fs", "rt-multi-thread"] }
xdg = "3.0.0"
[target.'cfg(target_os = "android")'.dependencies]
tokio = { version = "1.48.0", default-features = false, features = ["rt-multi-thread"] }
[target.'cfg(target_arch = "wasm32")'.dependencies]
wasm-bindgen = "0.2.106"
wasm-bindgen-futures = "0.4.56"
web-sys = "0.3.83"
[dependencies.slint]
version = "1.14.1"
default-features = false
features = ["live-preview", "backend-winit-wayland", "renderer-femtovg", "compat-1-2"]
features = [
"live-preview",
"backend-winit-wayland",
"renderer-femtovg",
"compat-1-2",
"backend-android-activity-06",
]
[build-dependencies]
slint-build = "1.14.1"
# See https://github.com/rust-mobile/cargo-apk?tab=readme-ov-file#manifest
[package.metadata.android]
package = "sh.nubo.Inkopslista"
resources = "./android/resources"
[package.metadata.android.signing.dev]
path = "android/keystore/default.keystore"
keystore_password = "123456"
[package.metadata.android.signing.release]
path = "android/keystore/default.keystore"
keystore_password = "123456"
[package.metadata.android.application]
label = "Inköpslista"
icon = "@drawable/icon"
Binary file not shown.
Binary file not shown.

After

Width:  |  Height:  |  Size: 28 KiB

+8
View File
@@ -0,0 +1,8 @@
#[unsafe(no_mangle)]
fn android_main(app: slint::android::AndroidApp) {
slint::android::init(app).unwrap();
if let Err(e) = crate::run() {
eprintln!("{e:?}");
}
}
+6
View File
@@ -4,6 +4,9 @@
mod config;
mod runtime;
#[cfg(target_os = "android")]
mod android;
#[cfg(target_arch = "wasm32")]
mod wasm;
@@ -96,6 +99,9 @@ pub fn run() -> Result<(), anyhow::Error> {
#[cfg(target_arch = "wasm32")]
let conf = Config::default();
#[cfg(target_os = "android")]
let conf = Config::default();
state.set_server_address(conf.address.to_shared_string());
let conf_shared = Arc::new(Mutex::new(conf));