PackageTrack
Sign in Get early access

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 2026
2023 2024 2025 2026
Release Pre-release Withdrawn

Releases

latest 34
  1. 1.0.3 30 Jul 2026
    Release notes
    • Fix JNI build errors on Linux arm64.
    Open source →
    Release notes
    • Fix JNI build errors on Linux arm64.
    Open source →
  2. 1.0.2 28 Jul 2026
    Release notes
    • Revert an unnecessary (and breaking) KGP migration.
    Open source →
    Release notes
    • Revert an unnecessary (and breaking) KGP migration.
    Open source →
  3. 1.0.1 27 Jul 2026 withdrawn
    Release notes
    • 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).
    Open source →
  4. 1.0.0 01 Apr 2026
    Release notes
    • Breaking Change: The Flutter specific APIs Jni.androidApplicationContext and Jni.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, JMap etc) are now direct code generated wrappers around the Java objects, so are less Darty. Instead there are now Darty adapter classes you can access via asDart().
      • No more nullable JType classes, only JType classes, and the JType class is simplified.
      • It is no longer necessary to pass around the JType in many cases where it used to be required.
    • Added Jni.captureStackTraceOnRelease which defaults to false. When this is set, the stack traces of the release points will be stored for JObjects to help debug DoubleReleaseError and UseAfterReleaseErrors. This includes the points where JObjects have been registered to be released by an arena via JObject.releaseBy.
    • Changed the behavior of JObject.releasedBy. It now does not throw a DoubleReleaseError if the object was manually released before the end of arena.
    • Added JThrowable class which inherits from JObject and implements Exception.
    • Breaking Change: JniException has been deleted. Java exceptions are now thrown as JThrowable instead. JThrowable holds an actual Java exception, instead of just holding a string message. It's a JObject, so the usual .isA and .as methods work to cast the JThrowable to 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, and JString have changed to be more consistent with other APIs. For example, JBoolean.booleanValue is now JBoolean.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.
    Open source →
  5. 0.15.2 14 Nov 2025
    Release notes
    • Do not fail flutter build if JDK is not found for desktop.
    Open source →
  6. 0.15.1 12 Nov 2025
    Release notes
    • Breaking Change: Removed the engineId argument from Jni.androidApplicationContext as the application context is not dependant on the engine ID.
    Open source →
  7. 0.15.0 07 Nov 2025 withdrawn
    Release notes
    • Breaking Change: Made Jni.env internal.
    • Breaking Change: Renamed JObjType to JType.
    • Breaking Change: Made all of the type classes internal.
    • Breaking Change: Removed Jni.getApplicationClassLoader(), Jni.getCurrentActivity(), and Jni.getCachedApplicationContext(). Instead use Jni.androidApplicationContext(engineId) to access the application context and use Jni.androidActivity(engineId) to acccess the activity.
    • Update to the latest lints.
    Open source →
  8. 0.14.2 23 May 2025
    Release notes
    • Fixed a bug where certain method of JList, JSet, and JMap did not work with nullable elements.
    • Fixed a bug in JList.lastIndexOf.
    Open source →
  9. 0.14.1 27 Feb 2025
    Release notes
    • Updated bin/setup.dart to use Gradle instead of Maven for building Java sources. Added gradle executables and bootstrap jars #2003
    • Added JObject.isInstanceOf which checks whether a JObject is 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.
    Open source →
  10. 0.14.0 31 Jan 2025
    Release notes
    • Added DynamicLibraryLoadError which is thrown when the dynamic library fails to load. HelperNotFoundError will 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 dylibDir when running Jni.spawn from Dart standalone, instead use the default value of build/jni_libs.
    • Added JArray.of, which allows a JArray to be constructed from an Iterable.
    • Added JObject.isA, which checks whether a JObject is an instance of a java typeclass.
    • Do not require JAWT when building for desktop.
    • Added JByteArray.from, which allows a JByteArray to be constructed from an Iterable<int>.
    Open source →
  11. 0.13.0 13 Dec 2024
    Release notes
    • Breaking Change: Separated primitive arrays from object arrays. Previously, a primitive array like an array of bytes was typed JArray<jbyte>. Now JArray<T> only accepts JObjects as types and primitive arrays like arrays of bytes have their own types such as JByteArray.

      This enables all arrays to implement Iterable which makes it possible to use them in a for-loop or use methods such as map on 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, and toString.

    Open source →
  12. 0.12.2 15 Nov 2024
    Release notes
    • Added JniUtils.fromReferenceAddress which helps with sending JObjects through method channels. You can send the address of the pointer as long and 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 toString on a null object.
    Open source →
  13. 0.12.0 01 Oct 2024
    Release notes
    • Breaking Change: Renamed castTo to as.
    • Renamed library internal_helpers_for_jnigen to _internal.
    • Using 16KB page size to support Android 15.
    • Added JImplementer which enables building an object that implements multiple Java interfaces.
    Open source →
  14. 0.11.0 29 Aug 2024
    Release notes
    • Breaking Change Removed Jni.accessors.
    • Made most Jni.env methods into leaf functions to speed up their execution.
    • Removed the dependency on kotlin_gradle_plugin.
    Open source →
  15. 0.10.1 11 Jul 2024
    Release notes
    • Fixed an issue with JObject.castTo where the type checking could fail in debug mode.
    • Used package:dart_flutter_team_lints.
    Open source →
  16. 0.10.0 11 Jul 2024 withdrawn

    Nothing published for this version

  17. 0.9.3 25 Jun 2024
    Release notes
    • Added lifetime event handling for the thread-local JNI env. Now jvm.DetachNativeThread is called when the thread detaches as recommended here.
    • Removed JValueChar.fromString constructor.
    Open source →
  18. 0.9.2 14 May 2024
    Release notes
    • Bumped minSdk to 21.
    Open source →
  19. 0.9.1 14 May 2024
    Release notes
    • Fixed compilation on macOS for consumers that don't use JNI on macOS (which is still not supported) (#1122).
    Open source →
  20. 0.9.0 02 May 2024
    Release notes
    • Breaking Change (#1004): Changed the return type operator [] of JArray<jchar> to int instead of String. Similarly, change the argument type of operator []= to accept int.
    • Added getRange method to JArray of primitive types that returns a TypedData list depending on the kind of the array.
    • Improved the performance of JArray's setRange and operator []=.
    Open source →
  21. 0.8.0 04 Apr 2024
    Release notes
    • Breaking Change (#981):

      • JObject.reference now returns a JReference instead of Pointer<Void>.

      • .fromRef constructors are now called .fromReference and they take a JReference instead of Pointer<Void>.

      • JObject reflective field retrieving and method calling methods are removed. Use JClass API instead.

      • The following Jni.accessors methods have been removed:

        • getClassOf
        • getMethodIDOf
        • getStaticMethodIDOf
        • getFieldIDOf
        • getStaticFieldIDOf
        • newObjectWithArgs
        • callMethodWithArgs
        • callStaticMethodWithArgs

        Instead use the JClass API.

      • Jni.findJClass is replaced with JClass.forName(String name)

      • JClass has been refactored. Instead of directly calling methods, getting and setting fields, use JClass.instanceMethodId, JClass.staticMethodId, JClass.constructorId, JClass.instanceFieldId, and JClass.staticFieldId to first get access to the member.

      • Renamed JObject.getClass() to JObject.jClass.

      • Removed Jni.deleteAllRefs.

    • Breaking Change (#548): Converted various Exceptions into Errors:

      • UseAfterReleaseException -> UseAfterReleaseError
      • DoubleReleaseException -> DoubleReleaseError
      • SpawnException -> JniError (It's now a sealed class)
      • JNullException -> JNullError
      • InvalidCallTypeException -> InvalidCallTypeError
      • HelperNotFoundException -> HelperNotFoundError
      • JvmExistsException -> JniVmExistsError
      • NoJvmInstanceException -> NoJvmInstanceError
    • Breaking Change: Removed InvalidJStringException.

    • Breaking Change: JType is now sealed.

    • Breaking Change: Primitive types and their type classes are now final.

    • Breaking Change: JArray.filled now uses the generated type class of the fill object and not its Java runtime type.

    • JObjects now check the types using instanceof in debug mode when using castTo.

    • 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);
      });
      
    Open source →
  22. 0.7.3 20 Mar 2024
    Release notes
    • Fixed a bug where get(Static)MethodID and get(Static)FieldID could access null and throw.
    Open source →
  23. 0.7.2 03 Nov 2023
    Release notes
    • Fixed a bug where reading non-null terminated strings would overflow.
    • Use package:dart_flutter_team_lints.
    Open source →
  24. 0.7.1 02 Nov 2023
    Release notes
    • Removed macOS Flutter plugin until package:jni supports it (#780).
    Open source →
  25. 0.7.0 13 Sep 2023
    Release notes
    • Breaking Change (#563): Added JBuffer and JByteBuffer classes as default classes for java.nio.Buffer and java.nio.ByteBuffer respectively.
    • Breaking Change: Made the type classes final.
    • Fixed a bug where addAll, removeAll and retainAll in JSet would run their respective operation twice.
    • Fixed a bug where JList.insertAll would not throw the potentially thrown Java exception.
    Open source →
  26. 0.6.1 01 Sep 2023
    Release notes
    • Depend on the stable version of Dart 3.1.
    Open source →
  27. 0.6.0 01 Sep 2023
    Release notes
    • Breaking Change (#707): Renamed delete* to release*.
    • Added PortProxy and related methods used for interface implementation.
    • Added the missing binding for java.lang.Character.
    Open source →
  28. 0.5.0 31 May 2023
    Release notes
    • Breaking Change (#711): Java primitive types are now all lowercase like jint, jshort, ...
    • The bindings for java.util.Set, java.util.Map, java.util.List and the numeric types like java.lang.Integer, java.lang.Boolean, ... are now included in package:jni.
    Open source →
  29. 0.4.0 02 May 2023
    Release notes
    • Type classes now have superCount and superType getters used for type inference.
    Open source →
  30. 0.3.0 16 Feb 2023
    Release notes
    • Added PortContinuation used for suspend fun in Kotlin.
    • dartjni now depends on dart_api_dl.h.
    Open source →
  31. 0.2.1 26 Jan 2023
    Release notes
    • Added .clang-format to pub.
    Open source →
  32. 0.2.0 25 Jan 2023
    Release notes
    • Added array support
    • Added generic support
    • JniX turned into JX for a more terse code.
    Open source →
  33. 0.1.1 22 Sep 2022
    Release notes
    • Windows support for running tests and examples on development machines.
    Open source →
  34. 0.1.0 12 Sep 2022
    Release notes
    • Initial version: Android and Linux support, JObject API
    Open source →

Every package, every release, already written down.

The archive is open and free. Watching your own project is what we are building next.

Browse the archive