packages icon indicating copy to clipboard operation
packages copied to clipboard

[path_provider_android] Changes internal implementation to use JNI

Open bparrishMines opened this issue 5 months ago • 4 comments

https://developer.android.com/guide/components/processes-and-threads

Pre-Review Checklist

If you need help, consider asking for advice on the #hackers-new channel on Discord.

Note: The Flutter team is currently trialing the use of Gemini Code Assist for GitHub. Comments from the gemini-code-assist bot should not be taken as authoritative feedback from the Flutter team. If you find its comments useful you can update your code accordingly, but if you are unsure or disagree with the feedback, please feel free to wait for a Flutter team member's review for guidance on which automated comments should be addressed.

[^1]: Regular contributors who have demonstrated familiarity with the repository guidelines only need to comment if the PR is not auto-exempted by repo tooling.

bparrishMines avatar Aug 07 '25 16:08 bparrishMines

cc @stuartmorgan-g for early review

bparrishMines avatar Aug 13 '25 19:08 bparrishMines

@HosseinYousefi Have you seen this error on Windows for JNI:

Changed 65 dependencies!
10 packages have newer versions incompatible with dependency constraints.
Try `flutter pub outdated` for more information.
Building Windows application...                                 
Nuget.exe not found, trying to download or use cached version.
CMake Error at C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/Common7/IDE/CommonExtensions/Microsoft/CMake/CMake/share/cmake-3.19/Modules/FindPackageHandleStandardArgs.cmake:218 (message):
  Could NOT find JNI (missing: JAVA_AWT_LIBRARY JAVA_JVM_LIBRARY
  JAVA_INCLUDE_PATH JAVA_INCLUDE_PATH2 JAVA_AWT_INCLUDE_PATH)
Call Stack (most recent call first):
  C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/Common7/IDE/CommonExtensions/Microsoft/CMake/CMake/share/cmake-3.19/Modules/FindPackageHandleStandardArgs.cmake:582 (_FPHSA_FAILURE_MESSAGE)
  C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/Common7/IDE/CommonExtensions/Microsoft/CMake/CMake/share/cmake-3.19/Modules/FindJNI.cmake:382 (FIND_PACKAGE_HANDLE_STANDARD_ARGS)
  flutter/ephemeral/.plugin_symlinks/jni/src/CMakeLists.txt:32 (find_package)


Building Windows application...                                    11.5s
Unable to generate build files

bparrishMines avatar Sep 25 '25 19:09 bparrishMines

This is similar to https://github.com/getsentry/sentry-dart/issues/3033

So I write what I wrote there here as well:

@HosseinYousefi maybe you can confirm

issue: we're using JNI on Android but also means Flutter Desktop targets are affected due to flutter's plugin system. we don't use any JNI api during runtime on Desktop -> will end users need java installed in that case on Desktop using the app?

End users don't need to have Java installed as long as we're not using JNI on Windows (which I assume we're not here).

This is an issue with Flutter's plugin system. You could technically spawn JVM and use package:jni on Windows. This will be solved once we use the newly introduced build hooks for building package:jni's native library instead. Sentry could pass a parameter to specify that it's only using JNI on android and not on desktop.

Originally posted by @HosseinYousefi in #3033

I can fix this by making the windows build show a warning instead of an error if it couldn't find JDK.

HosseinYousefi avatar Sep 26 '25 11:09 HosseinYousefi

Oops, I lost a comment because GitHub won't let me save a comment on the deleted file for reason. I had this on the deleted Dart unit tests:

I would expect these tests to be moved to the integration test runner rather than removed, so that we are still unit testing how we handle specific responses to from the system layer.

stuartmorgan-g avatar Oct 10 '25 14:10 stuartmorgan-g

Greetings from stale PR triage! 👋 Is this change still on your radar?

Piinks avatar Dec 15 '25 22:12 Piinks

The PR was blocked by jni breaking Windows, but I believe jni 0.15.2 resolves the blocker.

stuartmorgan-g avatar Dec 16 '25 21:12 stuartmorgan-g