wasmtime icon indicating copy to clipboard operation
wasmtime copied to clipboard

wasmtime on Android

Open anderspitman opened this issue 8 months ago • 4 comments

I recently managed to get wasmtime-py working on Android (see https://github.com/bytecodealliance/wasmtime-py/pull/279, thanks @alexcrichton!)

I'd like to get it working in a native Anrdoid app via Kotlin bindings. I see Java was previously asked about (https://github.com/bytecodealliance/wasmtime/issues/8394), and I see a couple 3rd-party wasmtime-java repos that are both a couple years without updates (https://github.com/kawamuray/wasmtime-java, https://github.com/bluejekyll/wasmtime-java).

Is anyone currently running wasmtime on Android in production? Are there recommended libraries to get started with?

anderspitman avatar May 09 '25 17:05 anderspitman

I'm not aware of any users using Wasmtime on Android and/or through Java at this time myself, but maybe others do? My guess though is that you're blazing the trail here though.

alexcrichton avatar May 09 '25 21:05 alexcrichton

@alexcrichton starting to dig into this. Do you happen to know if the Android builds are limited to interpreter mode, or if the cranelift backend is expected to work?

anderspitman avatar May 21 '25 23:05 anderspitman

I believe Cranelift should be enabled by default, yeah, although if it's not or if you see problems definitely let us know! (Note that we don't test Android though so while I don't know why it wouldn't work I also wouldn't be certain it would work)

alexcrichton avatar May 22 '25 00:05 alexcrichton

@anderspitman @alexcrichton

I've implemented a wasmtime Kotlin/wasi implementation. This can run perfectly on an Android ARM64v8a device and load the wasm artifacts generated by Kotlin/wasi. On Android, it loads these wasm artifacts via wasmtime and calls functions from the wasm file. It's currently under development. The plan is to support the Kotlin Multiplatform platform after JNI integration, enabling bidirectional RPC communication. Android already supports this, and support will be added for Windows, macOS, and Linux. iOS requires implementation via Kotlin/native and will need debugging. You can check the main2 branch, which is currently being updated; it will be removed and reconfigured later.

Additionally, on Android, the minimum file size cannot be used; a full-featured artifact should be implemented, supporting AOT and JIT. The configuration also differs from desktop.

https://github.com/crowforkotlin/wasmline/tree/main2

Image

crowforkotlin avatar Nov 30 '25 15:11 crowforkotlin