[path_provider_android] Changes internal implementation to use JNI
https://developer.android.com/guide/components/processes-and-threads
Pre-Review Checklist
- [ ] I read the Contributor Guide and followed the process outlined there for submitting PRs.
- [ ] I read the Tree Hygiene page, which explains my responsibilities.
- [ ] I read and followed the relevant style guides and ran the auto-formatter.
- [ ] I signed the CLA.
- [ ] The title of the PR starts with the name of the package surrounded by square brackets, e.g.
[shared_preferences] - [ ] I linked to at least one issue that this PR fixes in the description above.
- [ ] I updated
pubspec.yamlwith an appropriate new version according to the pub versioning philosophy, or I have commented below to indicate which version change exemption this PR falls under[^1]. - [ ] I updated
CHANGELOG.mdto add a description of the change, following repository CHANGELOG style, or I have commented below to indicate which CHANGELOG exemption this PR falls under[^1]. - [ ] I updated/added any relevant documentation (doc comments with
///). - [ ] I added new tests to check the change I am making, or I have commented below to indicate which test exemption this PR falls under[^1].
- [ ] All existing and new tests are passing.
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.
cc @stuartmorgan-g for early review
@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
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.
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.
Greetings from stale PR triage! 👋 Is this change still on your radar?
The PR was blocked by jni breaking Windows, but I believe jni 0.15.2 resolves the blocker.