TLDR Web Dev · MISCELLANEOUS
INJECTING JAVA FROM NATIVE LIBRARIES ON ANDROID
Summary from the TLDR Web Dev newsletter
On Android, accessing advanced phone capabilities like Bluetooth or certain network features from Rust requires using the Java SDK via JNI because the NDK and Libc lack direct APIs. While JNI allows calling Java from Rust, traditionally, creating new Java classes from Rust was thought to be impossible. However, using `DexClassLoader`, Rust libraries can compile and inject necessary Java classes at runtime, making them more modular and easier for other developers to use.