Dalvik VM target

Is it possible (as of 2024) to use Rust as if it were Kotlin on Android Studio? I don't want to deal with NDK nor A.S., and I want to write APKs that are cross-platform (no machine-code, only byte-code)

I wrote "Dalvik" because it's less ambiguous than "ART". I actually want to target A.R.T. (not the same as JVM)

Should I open a pre-RFC on Internals?

There is no Rust-to-Java or Rust-to-Dalvik compiler at the moment. Your best bet is to use the NDK and/or the jni.

Alternatively, you could try using react native with rust-compiled-to-wasm, but I don't that is good idea.

1 Like

Thanks for answering! But what about LLVM->JVM?

About Wasm, that gives me an idea: Build for some runtime (such as wasmtime) and install said runtime on Termux. The problem is that the API is very limited compared to LL-AM and Tasker.

off-topic

For a long time, I've been considering to make my own runtime. Something like AM but with a textual lang such as JS or Rust. Python is out of the question, because it's hard to optimize, and it seems easier to expose API in JS (I mean "Web APIs" such as console.log).

V8 and rustc both offer nice optimizations. TS and Rust are more maintainable than AM "flows", and they also have a module system.

A big reason to prefer JS over Rust is that Rust has no REPL (yet). I believe a REPL is essential for the runtime I'm picturing.

Of course, typing on a phone is awkward, but not all Android devices have small displays, so I guess the work may be worth it?

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.