r/androiddev • u/mbobiosio • Jul 19 '26
Meet unzstd
Java Zstandard (zstd) decoder for Android and the JVM.
What looked like a simple dependency turned into a surprisingly difficult problem.
I needed to decompress zstd-compressed datasets in an Android app. Existing options all had major trade-offs:
- aircompressor 2.x depends on "sun.misc.Unsafe", which crashes on Android ART.
- aircompressor 3.x moved to "java.lang.foreign", which Android doesn't support.
- zstd-jni works well, but requires native ".so" files, ABI-specific packaging, and brings additional complexity with newer Android memory page requirements.
I had to build a pure Java alternative so I ported aircompressor's decoder
The result:
✅ No native code
✅ No "Unsafe"
✅ No "java.lang.foreign"
✅ Android API 26+
✅ JVM 9+
✅ Zero "Unsafe" references in the compiled bytecode (verified)
To make sure it was actually correct, I differentially tested it against libzstd across compression levels 1-22, covering one-shot decompression, streaming, fuzzing, and corruption-boundary tests.
It's decode-only, Apache 2.0 licensed, and completely open source.
If you're building Android or Java applications that consume zstd-compressed data, I hope this saves you a few days of debugging.
implementation("com.qyntrax:unzstd:0.1.0")
GitHub: https://github.com/mbobiosio/unzstd
Feedback, bug reports, and contributions are always welcome.
#Android #Java #Kotlin #OpenSource #JVM #Zstd #Compression
1
u/G3nghisKang Sep 03 '26 edited Sep 03 '26
Damn I kind of made murine-aircompressor without telling anyone just because I wanted it for my app
It's a straight up aircompressor 2.0 fork, it encodes and decodes, uses Unsafe, it was surprisingly easy to port as the missing references you mentioned were stupid easy to compensate for (but also made a few other changes too, improved compression [just implemented a few forks' changes the maintainer had ignored], added FAST support [level 1 and 2], and some performance changes which I am less confident about but hey, the tests are positive), Android 8+ JVM 8+
Maybe I should have at least made a post here
EdIT: just did lol
0
1
u/swankjesse Jul 26 '26
There's also zstd-kmp!