Viewing version 0.1.0. Open the latest package page.
jni
0.1.0Library to access JNI from dart and flutter
Readme
jni (experimental module)
This is a utility library to access JNI from Dart / Flutter code, intended as a supplement for jnigen code generator, as well as provide the common base components (such as managing the JVM instance) to the code generated by jnigen.
This library contains:
-
functions to access the JNIEnv and JavaVM variables from JNI, and wrapper functions to those provided by JNI. JNIEnv is exposed via
GlobalJniEnvtype which provides a thin abstraction over JNIEnv, so that it can be used from multiple threads. -
Functions to spawn a JVM on desktop platforms (
Jni.spawn). -
Some Android-specific helpers (get application context and current activity references).
-
JniObjectclass, which provides base class for classes generated by jnigen.
This is intended for one-off / debugging uses of JNI, as well as providing a base library for code generated by jnigen.
To generate type-safe bindings from Java libraries, use jnigen.
Version note
This library is at an early stage of development and we do not provide backwards compatibility of the API at this point.
Documentation
The test/ directory contains files with comments explaining the basics of this module, and the example/ directory contains a flutter example which also touches some Android-specifics.
Using this library assumes some familiarity with JNI - it's threading model and object references, among other things.
jnigen
This library is a part of jnigen - a 2022 GSoC project.
The broader aim of jnigen is making Java APIs accessible from dart in an idiomatic way.
Changelog
0.1.0
- Initial version: Android and Linux support, JniObject API
Installing
export PUB_HOSTED_URL=https://pub.mirror.p-hatan.ir
flutter pub add 'jni:0.1.0'pubspec.yaml
name: jni
description: Library to access JNI from dart and flutter
version: 0.1.0
homepage: https://github.com/dart-lang/jnigen
environment:
sdk: ">=2.17.1 <3.0.0"
flutter: ">=2.11.0"
dependencies:
plugin_platform_interface: ^2.0.2
ffi: ^2.0.0
path: ^1.8.0
package_config: ^2.1.0
args: ^2.3.1
dev_dependencies:
## After running `dart run ffigen --config ffigen.yaml` there
## should be no changes.
ffigen:
path: third_party/ffigen_patch_jni
flutter_lints: ^2.0.0
test: ^1.21.1
# The following section is specific to Flutter packages.
flutter:
plugin:
platforms:
linux:
ffiPlugin: true
windows:
ffiPlugin: true
macos:
ffiPlugin: true
android:
ffiPlugin: true
package: com.github.dart_lang.jni
pluginClass: JniPlugin
Version history
| Version | Published | Archive | SHA-256 |
|---|---|---|---|
| 0.1.0 | Cached · Upstream SHA-256 matched | Download | b237560e…ae6db4 |
| 0.1.1 | Cached · Upstream SHA-256 matched | Download | 47000d71…3f9cd8 |
| 0.2.0 | Cached · Upstream SHA-256 matched | Download | bea8d106…48d578 |
| 0.2.1 | Cached · Upstream SHA-256 matched | Download | 075d1622…ff4e27 |
| 0.3.0 | Cached · Upstream SHA-256 matched | Download | d1361580…7feb3d |
| 0.4.0 | Cached · Upstream SHA-256 matched | Download | 1b5c3708…9946d7 |
| 0.5.0 | Cached · Upstream SHA-256 matched | Download | a19d9f63…b0143c |
| 0.6.0 | Cached · Upstream SHA-256 matched | Download | ef31e778…1ad72b |
| 0.6.1 | Cached · Upstream SHA-256 matched | Download | b4bed1f4…d2d02d |
| 0.7.0 | Cached · Upstream SHA-256 matched | Download | 6b322776…1baa72 |
| 0.7.1 | Cached · Upstream SHA-256 matched | Download | e63e1cca…76ffa2 |
| 0.7.2 | Cached · Upstream SHA-256 matched | Download | 0d88790b…885b43 |
| 0.7.3 | Cached · Upstream SHA-256 matched | Download | 499558e9…4e6611 |
| 0.8.0 | Cached · Upstream SHA-256 matched | Download | 63984817…c39222 |
| 0.9.0 | Cached · Upstream SHA-256 matched | Download | 4f20a803…3176af |
| 0.9.1 | Cached · Upstream SHA-256 matched | Download | 2a99a0cc…49f21c |
| 0.9.2 | Cached · Upstream SHA-256 matched | Download | 6f8e0433…8b665d |
| 0.9.3 | Cached · Upstream SHA-256 matched | Download | 85cf3fbc…8988a8 |
| 0.10.0 | Cached · Upstream SHA-256 matched | Download | 08a0074b…ca2270 |
| 0.10.1 | Cached · Upstream SHA-256 matched | Download | f377c585…acba4b |
| 0.11.0 | Cached · Upstream SHA-256 matched | Download | caefbbf9…0d126f |
| 0.12.0 | Cached · Upstream SHA-256 matched | Download | 100fd0a7…5e595b |
| 0.12.2 | Cached · Upstream SHA-256 matched | Download | 459727a9…62ac4e |
| 0.13.0 | Cached · Upstream SHA-256 matched | Download | 3296e432…ca5faa |
| 0.14.0 | Cached · Upstream SHA-256 matched | Download | 302f50fd…db3b1f |
| 0.14.1 | Cached · Upstream SHA-256 matched | Download | cfd663ec…6adba6 |
| 0.14.2 | Cached · Upstream SHA-256 matched | Download | d2c36108…2b3da1 |
| 0.15.0 | Cached · Upstream SHA-256 matched | Download | 5b8d72fa…cdf76b |
| 0.15.1 | Cached · Upstream SHA-256 matched | Download | b4d27985…61f3df |
| 0.15.2 | Cached · Upstream SHA-256 matched | Download | 8706a77e…3ea12d |
| 1.0.0 | Cached · Upstream SHA-256 matched | Download | c2230682…b2e68f |
| 1.0.1 | Cached · Upstream SHA-256 matched | Download | ca1efa31…93a4f4 |
| 1.0.2 | Cached · Upstream SHA-256 matched | Download | 5bc9a9da…d978d1 |
| 1.0.3 | Cached · Upstream SHA-256 matched | Download | f038e58b…04cbd3 |
| 1.1.0 | Cached · Upstream SHA-256 matched | Download | 6b9ca060…2f402d |
| 1.1.1 | Cached · Upstream SHA-256 matched | Download | d8df6dab…79813f |
Dependencies
args "^2.3.1"
ffi "^2.0.0"
package_config "^2.1.0"
path "^1.8.0"
plugin_platform_interface "^2.0.2"