r/androiddev • u/fireplay_00 • Aug 19 '26
Discussion Has anyone tried building Android apps with Rust + Native UI?
I have been currently assigned a project which needs to be cross platform + dynamic feature delivery (business requirements)
I'm thinking about writing my feature modules/business logic in rust to create native binaries which I can include with the android and IOS build and then include those .so/.a files with the build and communication between them will be from ffi (don't know which ffi approach works best raw JNI, UniFFI, or hand‑rolled C ABI)
Apple doesn't allow dynamic features installation so only android build will have that, IOS will just install everything at once
For UI I'm thinking to either go with Compose Multiplatform or just Compose for android side and Swift UI for IOS side (The app only has 3 screens so ui doesn't really matter as most features work in background)
Has anyone tried anything similar , where should I start experimenting, I don't want to waste time in approach that will be in vain, would love to hear your experience.
PS: Using rust as equivalent windows and MacOS app is also made in rust + imgui and I can use lots of code from there to make mobile app dev easier
8
u/ahzah3l Aug 19 '26
It works really well if you want to have the app/business logic written in Rust and the UI in Kotlin + Compose.
There are some tutorials online on how to integrate them - basically the Rust code is called like the C/C++ code would be, via JNI. Use this to bind them together and have Android Studio build the Rust code first and then the Kotlin one.
I've use it for a VPN app (the VPN code written in Rust) with Compose UI (in Kotlin). Make sure the crates you use in Rust are arm64 friendly - think this is the biggest problem you'll run into.
22
u/Opulence_Deficit Aug 19 '26
Sounds overly complicated, just to create a problem that KMP solved long time ago. I doubt you'll find anyone with that experience, sounds to me like a code golf, not a real project.
23
u/ozantas Aug 19 '26
https://kotlinlang.org/multiplatform/
3
u/gat0r87 Aug 19 '26
Yeah, if you're already thinking of using compose multiplatform for the ui, why would you NOT just use KMP for the whole shebang?
4
u/ssj_Thunder Aug 19 '26
We are using rust code for matrix client called via uniffi. The uniffi generates bindings that can be directly called via kotlin.. but its only for high performance code..
1
u/Fjordi_Cruyff Aug 20 '26
Have you considered the poor bastard(s) who will need to maintain this in the future?
1
u/zimmer550king Aug 24 '26
Just prompt Claude and you’ll get your app
3
u/ryanstackops Aug 21 '26
Go with UniFFI over raw JNI or hand-rolled C ABI, it generates the Kotlin/Swift bindings for you from your Rust interface so you're not hand-maintaining glue on both sides, and since Firefox mobile runs on it in production it's battle-tested. For UI, skip Compose Multiplatform, with only 3 screens and most logic running in the background, native Compose + SwiftUI is simpler and avoids extra build complexity for basically no benefit. Start with the smallest UniFFI proof of concept, one function call each way, before porting real logic, since packaging (.so for all Android ABIs, XCFramework for iOS) is usually where people lose the most time, not the FFI itself. Also test your dynamic feature module against a JNI-loaded Rust .so early, there are known rough edges with native libs loading per split that you don't want to discover mid-feature-build.
2
u/TransportationNo1264 Aug 20 '26
Yes, we had a large app using shared rust code between iOS, android, and web. Overall it was pretty smooth but has some gotchas you have to look out for. Having the hard boundary of immutably was sometimes challenging.
2
u/Ok-Elderberry-2923 Aug 21 '26
I believe Proton (mail and other their apps) has shared Rust code on iOS and Android for performance gains. You could have a look at their blogs and open-source
1
u/biskitpagla Aug 20 '26
Android Studio doesn't support Rust unfortunately. You'll have a much better experience with KMP or C++ right now.
1
u/Zalenka Aug 21 '26
Wow you'll have 3x the code and you'll be managing the abstraction the whole time.
I get why some business person would want this and it shows with all of the solutions for cross-platform frameworks.
In the end count up the shared actual logic. I'm sure it will be scant.