slint, 🚀 Developing Slint's Android port came with some interesting challenges. Accessing Java API without drowning in JNI complexity led us to a unique trick how to include Java in a Rust crate.
Our solution? 1. Compile Java to dalvik bytecode in build.rs 👉 https://github.com/slint-ui/slint/blob/f73c08304cf9ef34af987b621f3097a68819f362/internal/backends/android-activity/build.rs#L43. 2. Bundle it with include_bytes! in the binary. 3 At runtime, work the magic with InMemoryDexClassLoader 👉 https://github.com/slint-ui/slint/blob/f73c08304cf9ef34af987b621f3097a68819f362/internal/backends/android-activity/javahelper.rs#L29 . #RustLang #AndroidDev
Add comment