Get the latest tech news
Injecting Java from native libraries on Android
3 August 2025 When you're writing Rust and you want cross-platform support, Android is uniquely peculiar. Many OS functions that we take for granted when developing on desktop platforms are more complicated to access.
If your code is purely computation or it's using std to do basic things like open a TCP socket or write to a file then this tends to work. If you're working under this perspective, either Rust on Android is limited to doing things that don't require callbacks or you have to ensure that the classes you need already exist in the JVM. If your Rust code wants to support Android but it needs some Java to do its job then it can bring that along in a self-contained manner and inject it and the person who included your library doesn't have to worry about a thing beyond editing Cargo.toml.
Or read this on Hacker News