Fix tests
diff --git a/.github/workflows/jnigen.yaml b/.github/workflows/jnigen.yaml
index b4d5078..2a128ae 100644
--- a/.github/workflows/jnigen.yaml
+++ b/.github/workflows/jnigen.yaml
@@ -366,6 +366,7 @@
cache-key: 'flutter-:os:-:channel:-:version:-:arch:-:hash:'
- uses: actions/setup-java@99b8673ff64fbf99d8d325f52d9a5bdedb8483e9
with:
+ architecture: 'arm64'
distribution: 'temurin'
java-version: '11'
- run: flutter pub get
diff --git a/pkgs/jni/lib/src/jni.dart b/pkgs/jni/lib/src/jni.dart
index 1de4163..49205dc 100644
--- a/pkgs/jni/lib/src/jni.dart
+++ b/pkgs/jni/lib/src/jni.dart
@@ -57,12 +57,13 @@
static String? _dylibDir;
/// Sets the directory where dynamic libraries are looked for.
- /// On dart standalone, call this in new isolate before doing
- /// any JNI operation.
///
- /// (The reason is that dylibs need to be loaded in every isolate.
- /// On flutter it's done by library. On dart standalone we don't
- /// know the library path.)
+ /// On Dart-standalone, call this in new isolates before calling any JNI
+ /// functions.
+ ///
+ /// Dylibs need to be loaded in every isolate.
+ /// On Flutter it is done by library. On Dart-standalone the library path is
+ /// not known.
///
/// Flutter macOS applications should not call this.
static void setDylibDir({required String dylibDir}) {
diff --git a/pkgs/jnigen/test/simple_package_test/runtime_test_registrant.dart b/pkgs/jnigen/test/simple_package_test/runtime_test_registrant.dart
index bc257b6..96858b3 100644
--- a/pkgs/jnigen/test/simple_package_test/runtime_test_registrant.dart
+++ b/pkgs/jnigen/test/simple_package_test/runtime_test_registrant.dart
@@ -7,6 +7,7 @@
import 'dart:isolate';
import 'package:jni/jni.dart';
+import 'package:path/path.dart' show join;
import 'package:test/test.dart';
import '../test_util/callback_types.dart';
@@ -569,15 +570,18 @@
$MyInterfaceImpl(
voidCallback: voidCallbackResult.complete,
stringCallback: (s) {
+ Jni.setDylibDir(dylibDir: join('build', 'jni_libs'));
return (s.toDartString(releaseOriginal: true) * 2).toJString();
},
varCallback: (JInteger t) {
+ Jni.setDylibDir(dylibDir: join('build', 'jni_libs'));
final result =
(t.intValue(releaseOriginal: true) * 2).toJInteger();
varCallbackResult.complete(result);
return result;
},
manyPrimitives: (a, b, c, d) {
+ Jni.setDylibDir(dylibDir: join('build', 'jni_libs'));
if (b) {
final result = a + c + d.toInt();
manyPrimitivesResult.complete(result);
@@ -696,6 +700,7 @@
final stringConverter =
StringConverter.implement($StringConverterImpl(
parseToInt: (s) {
+ Jni.setDylibDir(dylibDir: join('build', 'jni_libs'));
final value = int.tryParse(s.toDartString());
if (value == null) {
// ignore: only_throw_errors