jni
A library to access JNI from Dart and Flutter that acts as a support library for package:jnigen.
1.0.3
5.6M downloads/mo
#137 most downloaded on pub.dev
dart-lang/native
What this package is like to depend on
Last release 25 days ago
30 Jul 2026
Release timing varies
gaps range from 2 weeks to 6 months
Nearly every release is documented
notes for 31 of 31 stable releases
3 versions withdrawn
withdrawn after publishing
4 years old
34 releases · first in 2022
7 releases in the last 12 months
see the full history below
Release timeline
34 releases · Sep 2022 to Jul 2026Releases
latest 34-
1.0.330 Jul 2026 -
1.0.228 Jul 2026 -
1.0.127 Jul 2026 withdrawnRelease notes
Open source →- Improve error message when JNI is used before Flutter plugin initialization.
- Improve no such method error handling.
- Fix memory leaks and deadlocks that can happen in callbacks, if the target isolate is shut down.
- Support versions 3.x of
package:package_config. - Make some internal-only FFI structs opaque. This is technically a breaking change, but it's extremely unlikely that any users are using these internal structs (and doing so would be a mistake).
-
1.0.001 Apr 2026Release notes
Open source →- Breaking Change: The Flutter specific APIs
Jni.androidApplicationContextandJni.androidActivity(int engineId)have been moved to a new package:jni_flutter. If you are using package:jni on Android you may need to add this new package as a dependency. - Breaking Change: All Java wrapper classes have been migrated to extension
types. The main effects are:
- All collections (
JList,JMapetc) are now direct code generated wrappers around the Java objects, so are less Darty. Instead there are now Darty adapter classes you can access viaasDart(). - No more nullable
JTypeclasses, onlyJTypeclasses, and theJTypeclass is simplified. - It is no longer necessary to pass around the
JTypein many cases where it used to be required.
- All collections (
- Added
Jni.captureStackTraceOnReleasewhich defaults tofalse. When this is set, the stack traces of the release points will be stored forJObjects to help debugDoubleReleaseErrorandUseAfterReleaseErrors. This includes the points whereJObjects have been registered to be released by anarenaviaJObject.releaseBy. - Changed the behavior of
JObject.releasedBy. It now does not throw aDoubleReleaseErrorif the object was manually released before the end of arena. - Added
JThrowableclass which inherits fromJObjectand implementsException. - Breaking Change:
JniExceptionhas been deleted. Java exceptions are now thrown asJThrowableinstead.JThrowableholds an actual Java exception, instead of just holding a string message. It's aJObject, so the usual.isAand.asmethods work to cast theJThrowableto the underlying Java exception. - Breaking Change: Class methods like getFoo, isFoo, and setFoo are now getters and setters in Dart.
- Breaking Change: APIs of
JBoolean,JByte,JCharacter,JDouble,JFloat,JInteger,JLong,JNumber,JShort, andJStringhave changed to be more consistent with other APIs. For example,JBoolean.booleanValueis nowJBoolean.toDartBool. - Fixed bugs that were causing crashes in interfaces after app close and reopen.
- Add compile time version checks to verify consistency of package:jni's versions vs JNIgen's generated code.
- Breaking Change: The Flutter specific APIs
-
0.15.214 Nov 2025 -
0.15.112 Nov 2025Release notes
Open source →- Breaking Change: Removed the
engineIdargument fromJni.androidApplicationContextas the application context is not dependant on the engine ID.
- Breaking Change: Removed the
-
0.15.007 Nov 2025 withdrawnRelease notes
Open source →- Breaking Change: Made
Jni.envinternal. - Breaking Change: Renamed
JObjTypetoJType. - Breaking Change: Made all of the type classes internal.
- Breaking Change: Removed
Jni.getApplicationClassLoader(),Jni.getCurrentActivity(), andJni.getCachedApplicationContext(). Instead useJni.androidApplicationContext(engineId)to access the application context and useJni.androidActivity(engineId)to acccess the activity. - Update to the latest lints.
- Breaking Change: Made
-
0.14.223 May 2025Release notes
Open source →- Fixed a bug where certain method of
JList,JSet, andJMapdid not work with nullable elements. - Fixed a bug in
JList.lastIndexOf.
- Fixed a bug where certain method of
-
0.14.127 Feb 2025Release notes
Open source →- Updated
bin/setup.dartto use Gradle instead of Maven for building Java sources. Added gradle executables and bootstrap jars #2003 - Added
JObject.isInstanceOfwhich checks whether aJObjectis an instance of a java class. - Fixed a bug where Java interfaces implemented in on the main thread in Dart could deadlock when invoked from the main thread outside the context of a Dart isolate.
- Updated
-
0.14.031 Jan 2025Release notes
Open source →- Added
DynamicLibraryLoadErrorwhich is thrown when the dynamic library fails to load.HelperNotFoundErrorwill only be thrown when the helper library cannot be found. - Update the README.md to include info about generating bindings for built-in java types.
- Do not require a
dylibDirwhen runningJni.spawnfrom Dart standalone, instead use the default value ofbuild/jni_libs. - Added
JArray.of, which allows aJArrayto be constructed from anIterable. - Added
JObject.isA, which checks whether aJObjectis an instance of a java typeclass. - Do not require JAWT when building for desktop.
- Added
JByteArray.from, which allows aJByteArrayto be constructed from anIterable<int>.
- Added
-
0.13.013 Dec 2024Release notes
Open source →-
Breaking Change: Separated primitive arrays from object arrays. Previously, a primitive array like an array of bytes was typed
JArray<jbyte>. NowJArray<T>only acceptsJObjects as types and primitive arrays like arrays of bytes have their own types such asJByteArray.This enables all arrays to implement
Iterablewhich makes it possible to use them in a for-loop or use methods such asmapon them. -
Added nullable type classes for all Java objects.
-
Fixed a problem where interfaces implemented in Dart would crash when calling the default object methods:
equals,hashCode, andtoString.
-
-
0.12.215 Nov 2024Release notes
Open source →- Added
JniUtils.fromReferenceAddresswhich helps with sendingJObjects through method channels. You can send the address of the pointer aslongand reconstruct the class using the helper method. - Fixed a bug where it would be possible for a type class inference to fail.
- Return 'null' when calling
toStringon a null object.
- Added
-
0.12.001 Oct 2024Release notes
Open source →- Breaking Change: Renamed
castTotoas. - Renamed library
internal_helpers_for_jnigento_internal. - Using 16KB page size to support Android 15.
- Added
JImplementerwhich enables building an object that implements multiple Java interfaces.
- Breaking Change: Renamed
-
0.11.029 Aug 2024Release notes
Open source →- Breaking Change Removed
Jni.accessors. - Made most
Jni.envmethods into leaf functions to speed up their execution. - Removed the dependency on
kotlin_gradle_plugin.
- Breaking Change Removed
-
0.10.111 Jul 2024Release notes
Open source →- Fixed an issue with
JObject.castTowhere the type checking could fail in debug mode. - Used
package:dart_flutter_team_lints.
- Fixed an issue with
-
0.10.011 Jul 2024 withdrawnNothing published for this version
-
0.9.325 Jun 2024Release notes
Open source →- Added lifetime event handling for the thread-local JNI env. Now
jvm.DetachNativeThreadis called when the thread detaches as recommended here. - Removed
JValueChar.fromStringconstructor.
- Added lifetime event handling for the thread-local JNI env. Now
-
0.9.214 May 2024 -
0.9.114 May 2024Release notes
Open source →- Fixed compilation on macOS for consumers that don't use JNI on macOS (which is still not supported) (#1122).
-
0.9.002 May 2024Release notes
Open source →- Breaking Change
(#1004): Changed the return
type
operator []ofJArray<jchar>tointinstead ofString. Similarly, change the argument type ofoperator []=to acceptint. - Added
getRangemethod toJArrayof primitive types that returns aTypedDatalist depending on the kind of the array. - Improved the performance of
JArray'ssetRangeandoperator []=.
- Breaking Change
(#1004): Changed the return
type
-
0.8.004 Apr 2024Release notes
Open source →-
Breaking Change (#981):
-
JObject.referencenow returns aJReferenceinstead ofPointer<Void>. -
.fromRefconstructors are now called.fromReferenceand they take aJReferenceinstead ofPointer<Void>. -
JObjectreflective field retrieving and method calling methods are removed. UseJClassAPI instead. -
The following
Jni.accessorsmethods have been removed:getClassOfgetMethodIDOfgetStaticMethodIDOfgetFieldIDOfgetStaticFieldIDOfnewObjectWithArgscallMethodWithArgscallStaticMethodWithArgs
Instead use the
JClassAPI. -
Jni.findJClassis replaced withJClass.forName(String name) -
JClasshas been refactored. Instead of directly calling methods, getting and setting fields, useJClass.instanceMethodId,JClass.staticMethodId,JClass.constructorId,JClass.instanceFieldId, andJClass.staticFieldIdto first get access to the member. -
Renamed
JObject.getClass()toJObject.jClass. -
Removed
Jni.deleteAllRefs.
-
-
Breaking Change (#548): Converted various
Exceptions intoErrors:UseAfterReleaseException->UseAfterReleaseErrorDoubleReleaseException->DoubleReleaseErrorSpawnException->JniError(It's now asealed class)JNullException->JNullErrorInvalidCallTypeException->InvalidCallTypeErrorHelperNotFoundException->HelperNotFoundErrorJvmExistsException->JniVmExistsErrorNoJvmInstanceException->NoJvmInstanceError
-
Breaking Change: Removed
InvalidJStringException. -
Breaking Change:
JTypeis nowsealed. -
Breaking Change: Primitive types and their type classes are now
final. -
Breaking Change:
JArray.fillednow uses the generated type class of thefillobject and not its Java runtime type. -
JObjects now check the types usinginstanceofin debug mode when usingcastTo. -
Breaking Change:
Jni.initDLApi()is removed. -
Added the ability to share
JObjects across isolates.// This now works. final foo = 'foo'.toJString(); Isolate.run(() { // `foo` is usable from another isolate. print(foo); });
-
-
0.7.320 Mar 2024Release notes
Open source →- Fixed a bug where
get(Static)MethodIDandget(Static)FieldIDcould access null and throw.
- Fixed a bug where
-
0.7.203 Nov 2023Release notes
Open source →- Fixed a bug where reading non-null terminated strings would overflow.
- Use
package:dart_flutter_team_lints.
-
0.7.102 Nov 2023 -
0.7.013 Sep 2023Release notes
Open source →- Breaking Change (#563):
Added
JBufferandJByteBufferclasses as default classes forjava.nio.Bufferandjava.nio.ByteBufferrespectively. - Breaking Change: Made the type classes
final. - Fixed a bug where
addAll,removeAllandretainAllinJSetwould run their respective operation twice. - Fixed a bug where
JList.insertAllwould not throw the potentially thrown Java exception.
- Breaking Change (#563):
Added
-
0.6.101 Sep 2023 -
0.6.001 Sep 2023Release notes
Open source →- Breaking Change (#707):
Renamed
delete*torelease*. - Added
PortProxyand related methods used for interface implementation. - Added the missing binding for
java.lang.Character.
- Breaking Change (#707):
Renamed
-
0.5.031 May 2023Release notes
Open source →- Breaking Change (#711):
Java primitive types are now all lowercase like
jint,jshort, ... - The bindings for
java.util.Set,java.util.Map,java.util.Listand the numeric types likejava.lang.Integer,java.lang.Boolean, ... are now included inpackage:jni.
- Breaking Change (#711):
Java primitive types are now all lowercase like
-
0.4.002 May 2023Release notes
Open source →- Type classes now have
superCountandsuperTypegetters used for type inference.
- Type classes now have
-
0.3.016 Feb 2023Release notes
Open source →- Added
PortContinuationused forsuspend funin Kotlin. dartjninow depends ondart_api_dl.h.
- Added
-
0.2.126 Jan 2023 -
0.2.025 Jan 2023Release notes
Open source →- Added array support
- Added generic support
JniXturned intoJXfor a more terse code.
-
0.1.122 Sep 2022 -
0.1.012 Sep 2022