slint,
@slint@fosstodon.org avatar

🚀 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 .

sergii,
@sergii@hachyderm.io avatar

@slint what challenges do you solve? You seem to be using jni in javahelper.rs

slint,
@slint@fosstodon.org avatar

@sergii We use a bit of JNI to call our own .java code instead of using pages of JNI to call native Java APIs. The challenge is to include .java code in a Rust crate, in a way that work regardless of the build tool used by the final application.

  • All
  • Subscribed
  • Moderated
  • Favorites
  • rust
  • ngwrru68w68
  • rosin
  • modclub
  • Youngstown
  • khanakhh
  • Durango
  • slotface
  • mdbf
  • cubers
  • GTA5RPClips
  • kavyap
  • DreamBathrooms
  • InstantRegret
  • magazineikmin
  • JUstTest
  • osvaldo12
  • tester
  • tacticalgear
  • ethstaker
  • Leos
  • thenastyranch
  • everett
  • normalnudes
  • anitta
  • megavids
  • cisconetworking
  • provamag3
  • lostlight
  • All magazines