Zstandard for Android
v1.5.7AndroidZstandard 1.5.7 for React Native apps on Android, precompiled for arm64-v8a devices and the x86_64 emulator as @crossbind/port-zstd-android.
Install
The whole flow, including Expo, is in the React Native playbook.
Usage
The examples the WebAssembly page runs, as Android compiles them: the same headers and the same calls. They are checked on the WebAssembly build.
Compress and decompress a buffer
The two calls most zstd code makes: ZSTD_compress, and ZSTD_decompress with the original size read back from the frame.
Choose a level, a checksum and a window
A context set up with ZSTD_CCtx_setParameter decides what every frame it writes looks like; ZSTD_getFrameHeader reads the choices back.
Compress small messages with a dictionary
Train once with ZDICT_trainFromBuffer, digest it once with ZSTD_createCDict and ZSTD_createDDict, then compress every message against it.
"Stream a file through zstd" writes its input with m.FS, which Android does not have; the C++ takes paths, so it works unchanged on files in the app's storage. It runs on the WebAssembly page.
What is different on Android
- The React Native plugin compiles your headers with the library inside Gradle's native build, so
npm run androidbuilds everything. - Named imports from
./native/<header>.hwork as on the web:await initNative()once, then call the classes. - There is no
m.FSand no/memfs: files live in the app's own storage, and your C++ takes their paths. - No Worker and no COOP or COEP:
runtime: 'mt'uses pthreads directly.
Other platforms
- Zstandard overview: the apps, every platform's setup and the packages.
- Zstandard for WebAssembly: browsers, Node.js and edge runtimes.
- Zstandard for iOS: React Native apps on iOS.
- Zstandard for WASI: command-line programs under wasmtime.
Facts on this page come from the port manifests in the repository and from what npm served on beta when the site was built. See the Libraries guide for the full consumer flow.