Compiling Rust from Android


I run a Android OS and can’t install android-rs-glue due to lack of manuals for installing Android SDK/NDK.

I’ve tried UserLAnd (Ubuntu emulator) app. Termux rust package won’t do (compiler crashes). Can I do $ rustup target install linux-androidebi-armv7 and target code for that arch (.a, .o) with Cargo w/o a toolchain installed?



OP ya’ need to check this link, hope it’s helpful

1 Like


I saw this, but the issue was in the SDK & NDK installation. They must be built by running a JAR, but requiring a command like:

$ java -jar sdk/install-manager

Installing JDK in UserLAnd’s Ubuntu complains about a Java class not found… These SDK developers don’t provide a minimum manual :confused:

I wanna know if I can already target ARM code, however; so then later I do manual tasks like wrapping recipients into a APK and provide API.



Btw Rust on Termux compiles for all target triples, but, even though I’m rooted, it crahes in internal storage for denied permission…



You need Android NDK. Building for Android without Android NDK is currently unsupported by Rust.

1 Like


I’ve tried it now and it generated ARMv7 code successfuly, but the compiler doesn’t seem to get IO privilleges in my internal storage.

The APK can be generated with some other way…



Woah, what a restraint… using android as a dev os… Anyway, I used to use termux alot when I was frequently away from my computer and so I installed Arch linux for it. I managed to install rust with the standard installation and just had to re-install gcc. There might be more things that you have to install to make it work, seeing as this wasn’t either a clean installation of arch or termux, but there shouldn’t be too many things. I mean, I got C# to compile on this thing so it can’t be too hard :grin:. Anyway something that I noticed is that the installation of rustup/cargo will not update your current $PATH and will also have some problems trying to create a new project. I ended up having to do this for a new cargo project:

USER=user bash -c "cargo new test_project"

Edit: here’s proof of the compilation:

Double edit:
I don’t have the sdk or ndk installed for this and it produces a linux binary, not an apk. For compiling an apk, I don’t think it’s possible with the host being android. At least not without traversing the labyrinth android native development on rust already is.

1 Like


I realized vanilla Termux and rust pkg work into Termux’s file system (cargo build -t=armv7-linux-androideabi), but doesn’t in my internal storage (/sdcard). I’ve downgraded to Lollipop Android, rooted it and yet rant termux-setup-storage. I’m thinking though it couldn’t be an issue to rely on Termux file system…

I’ve not seen that Termux Arch Linux… $ pkg install rust works here, though. UserLAnd also supports Arch Linux, but it has many internationalization assets (language data), and I don’t like that much.

Of everything, the Java N-IDE is the only app that generates APK (debuggable).