


Unfortunately most crates pull in a non-Rust dependency somewhere. In a traditional setup one would download Android’s official NDK. Without this you wouldn’t be able to compile Rust code for Android, but we unfortunately have to go beyond the Rust compiler and set up more.Įnter the linker: cargo invokes the host linker which isn’t able to compile applications for Android and doesn’t typically have support for the architectures mentioned above. Let’s start by uncovering how a typical Android build environment is constructed, before diving into the (Rust!) tools that automate this for you.įirst and foremost is Rust’s tier 2 compiler support for Android on popular architectures, most notably aarch64 and arm(v7) as used on most mobile phones and x86_64/ i686 for desktop (emulator) usage. Note that this story doesn’t intend to be a guide to using Rust on Android - rather serves to discuss the various options available for building Android binaries and applications, discuss technical details of their implementations, lay out caveats and finally figure out where to go next. Such apps contain no Java/Kotlin code and have to rely on whatever the Android system provides for so-called “native apps”. Going forward this story will cover pure Rust apps, which is how we build them at Traverse Research.
