Build Android apps using Rust and Iced

124 pointsposted 13 hours ago
by rekireki

43 Comments

denverllc

18 minutes ago

Will apps built with this framework be compatible with accessibility features?

nicoburns

9 hours ago

There is a huge amount of potential for shared infrastructure for "native integrations" for Rust UI projects. Think: React Native modules but in Rust.

I'm hoping this can be a reality sooner rather than later. But we're definitely lacking in manpower willing or able to work on the more foundational pieces. Winit in particular is sadly undermaintained. 1 or 2 people working full time on Winit and/or other platform integration pieces would do wonders for the ecosystem.

foresterre

4 hours ago

If you do it via React Native turbo modules, it is already possible, either using craby (1) or using uniffi-bindgen-react-native (2).

(1) https://github.com/leegeunhyeok/craby

(2) https://github.com/jhugman/uniffi-bindgen-react-native

nicoburns

4 hours ago

My understanding is that this only gives you access to C++ TurboModules? Binding to C++ is already easy in Rust (and odten Rust itself is a better choice for these "cross-platform business logic" kind of modules anyway). The value here is in unlocking bindings to the native platform APIs (which are mostly Java/Kotlin/Objc/Swift)

mdhb

an hour ago

I have no idea why people would want to write UI in Rust when Swift, Kotlin and Dart are much better suited for the job.

rekireki

3 hours ago

I would love to see RustActivity in Android one day, this would make the life much easier.

tonyhart7

6 hours ago

I mean cross platform is just "heavy work" in general

many company literally just give up use web wrapper instead because its just so much work

coldstartops

7 hours ago

Also on this topic I want to make a shout out to slint.dev ! (I've fiddled with it, and the syntax is extremely easy to grasp - very react-ish). Can use Rust/C as a binding language, and you can even choose the rendering engine (for example QT).

Tmpod

11 minutes ago

+1 for Slint! I worked with it for a while and enjoyed it quite a lot. Florian was working on a more glossy compinent library, not sure what has been made of it.

The DSL was pleasant but still had some rough edges. I think they made some nice QoL improvements in the latest releases, but I've not kept up with it. The compile times were quite something, though you can use the previewer tool to prototype faster.

Definitely worth giving Slint a shot, they learnt a lot from QML imo

vlovich123

9 hours ago

How does this compare for you with slint and dioxus? Dioxus uses web views but still a small app (based on Tauri which uses the OS web view instead of shipping the browser) and slint is native, but may have some slightly more unique license terms than typical Rust projects.

rekireki

4 hours ago

Dioxus is WebView, as you've mentioned. Though there's an experimental native renderer mentioned in the README, I would keep an eye on it. And slint should be the same kind of solution as I wrote about. When building native apps for Android, there's usually an issue with text inputs. NativeActivity doesn't support IME, and GameActivity is supposed to solve this. So in case of slint, I would check how they solved the text inputs.

nicoburns

3 hours ago

> Though there's an experimental native renderer mentioned in the README,

The native renderer should be available in 2026! (technically it's available now as a preview, but I wouldn't recommend using it until after the next release)

NoboruWataya

6 hours ago

Is there a reason you didn't mention Dioxus (other than not being familiar with it)? It explicitly has Android support as a goal, though (like all Rust GUI crates) it's a work in progress. I made a very simple app with it that works well in an Android emulator, I haven't tried actually side load it yet.

rekireki

4 hours ago

I left WebView based solutions out of scope. As you can see, I'm focusing on NativeActivity / GameActivity in my post. Though WebView brings you interesting options. For example, iced is inspired by Elm, and with Dioxus you can use Elm to build mobile apps.

Klonoar

2 hours ago

Dioxus has this idea stuck that it's webview only. They're actively working on (and ship at least in some form of alpha or beta) a native-renderer backend.

adastra22

4 hours ago

Dioxus is a very different API model, being an implementation of the Elm architecture. It’s really comparing apples to octopuses.

Klonoar

2 hours ago

Iced is the Elm architecture. Dioxus is more akin to modern React/whatever you want to call it.

Simplita

4 hours ago

This matches my experience too. Rust really shines once the app grows beyond simple flows. The upfront friction pays off later when debugging and concurrency issues would otherwise start piling up.

serial_dev

9 hours ago

You gotta check Crux: Cross-platform app development in Rust

https://github.com/redbadger/crux

phi-go

9 hours ago

Crux seems interesting to share app logic between platforms but I don't see how it helps actually render something. Don't you still need a gui framework that supports android or ios?

K0nserv

3 hours ago

Having spent time around cross platform rollouts and development I think something like Crux is the best approach. Building a complete UI framework to rival what iOS and Android provide natively is a monumental task.

bbkane

9 hours ago

Yes (from the README)

madduci

3 hours ago

I would like to get a benchmark of this against an app made with C++/Qt

androidinlimbo

6 hours ago

Android is in limbo, we need better free open source alternative.

ChadNauseam

5 hours ago

The Android Open Source Project is awesome. It's not hard to compile it yourself and run it on a pixel 9. The issue is the hardware imo. (And some of the apps in AOSP really suck, but the actual OS is great imo)

nicoburns

3 hours ago

The userspace being tied to the JVM is a massive pain. Certainly it's a lot harder to bind to than any other OS's system libraries.

brabel

2 hours ago

How so?? JVM bytecode should be much easier to bind to, as the existence of JVM alternative runtimes for nearly every language shows.

nicoburns

2 hours ago

Unless you're using a language that's specifically compile-to-jvm (e.g. Java, Kotlin or similar), almost nobody is using those JVM alternative runtimes. They're usually second-class runtimes that don't run the entire ecosystem of the target langauge. React Native runs JavaScript in a separate JS VM, Flutter is compiling Dart to native code with emdedded runtime, and Rust UI code also compiles to a native binary.

The "lingua franca" for language bindings is the C ABI which every other OS's platform libraries (Win32/Cocoa/GTK) support.

testdelacc1

5 hours ago

Account created one hour ago just to make this comment. Make it on your real account.

suddenlybananas

2 hours ago

Have you considered that people may join HackerNews who were not already on it?

bbkane

10 hours ago

Super impressive, can you link to this post in that issue?

I'd like to try iced, but switched to egui on the official Android support.

zwnow

4 hours ago

Does this support native components like camera access and stuff like that? I've learned with most libs like this I never have access to the android internals (Flutter as an example) and I'll always have to fallback to writing Kotlin components with broadcast channels or whatever.

rekireki

3 hours ago

It doesn't, and I had to write some Java to support clipboard.

zwnow

2 hours ago

I see, still a really cool project! Is accessing the internals simply not possible or just really hard to pull off programmatically? I am wondering about that because I never found anything in the android space to enable that without resorting to Kotlin/Java components.

nicoburns

2 hours ago

You can call into to the JVM via FFI (e.g. using the jni crate in Rust), but it's not very nice. And most of the abstractions people have written thus far seem to be primarily (or solely) targeting the "Java calls into native code" use case rather than the "native code calls into Java" use case.

I'd love to see something better here. I suspect it's possible.

RicoElectrico

7 hours ago

Not downplaying your project but a general related question. What's the deal with writing non-real-time application software in Rust? The stuff it puts you through doesn't seem to be worth the effort. C++ is barely usable for the job either.

nicoburns

4 hours ago

A lot of complex GUIs are written in C++ (or are thinish wrappers around an underlying toolkit that is C++). This is often for performabce and/or resource consumption reasons. UIs may not have hard realtime requirements, but they are expected to consistently run smoothly at 60fps+. And dealong with multiple screen sizes, vector graphics, univode text,r etc can involve a lot of computation.

Rust gives you the same performance as C++ with much nicer language to work with.

adastra22

4 hours ago

I don’t understand the question. Why would rust be confined to real-time applications?

IshKebab

5 hours ago

It turns out it is worth the effort. Once you have got past the "fighting the borrow checker" (which isn't nearly as bad as it used to be thanks to improvements to its abilities), you get some significant benefits:

* Strong ML-style type system that vastly reduces the chance of bugs (and hence the time spent writing tests and debugging).

* The borrow checker really wants you to have an ownership tree which it turns out is a really good way to avoid spaghetti code. It's like a no-spaghetti enforcer. It's not perfect of course and sometimes you do need non-tree ownership but overall it tends to make programs more reliable, again reducing debugging and test-writing time.

So it's more effort to write the code to the point that it will compile/run at all. But once you've done that you're usually basically done.

Some other languages have these properties (especially FP languages), but they come with a whole load of other baggage and much smaller ecosystems.

discreteevent

17 minutes ago

> So it's more effort to write the code to the point that it will compile/run at all. But once you've done that you're usually basically done.

Not if I don't know what I'm doing because it's something new. The way I'm learning how to do it is by building it. So I want to build it quickly so that I can get in more feedback loops as I learn. Also I want to learn by example, so I actually want to get runtime errors, not type system errors. Later when I do know what I am doing then, sure, I want to encode as much as I can in my types. But before that .. Don't get in my way!

nubinetwork

9 hours ago

Just in time for google to block sideloading and blocking new apps unless you pay them 6 figures...