Windows - Sentry 9.2.0 - Could NOT find JNI (missing: JAVA_INCLUDE_PATH JAVA_INCLUDE_PATH2 JVM)
Platform
Flutter Desktop Windows
Obfuscation
Enabled
Debug Info
Enabled
Doctor
[✓] Flutter (Channel stable, 3.32.5, on Microsoft Windows [Version 10.0.26100.4351], locale pl-PL) [529ms]
• Flutter version 3.32.5 on channel stable at c:\flutter
• Upstream repository https://github.com/flutter/flutter.git
• Framework revision fcf2c11572 (8 days ago), 2025-06-24 11:44:07 -0700
• Engine revision dd93de6fb1
• Dart version 3.8.1
• DevTools version 2.45.1
[✓] Windows Version (11 Home 64-bit, 24H2, 2009) [2,1s]
[!] Android toolchain - develop for Android devices (Android SDK version 35.0.0) [507ms]
• Android SDK at C:\Users\tomas\AppData\Local\Android\sdk
✗ cmdline-tools component is missing.
Try installing or updating Android Studio.
Alternatively, download the tools from https://developer.android.com/studio#command-line-tools-only and make sure
to set the ANDROID_HOME environment variable.
See https://developer.android.com/studio/command-line for more details.
✗ Android license status unknown.
Run `flutter doctor --android-licenses` to accept the SDK licenses.
See https://flutter.dev/to/windows-android-setup for more details.
[✓] Chrome - develop for the web [156ms]
• Chrome at C:\Program Files\Google\Chrome\Application\chrome.exe
[✓] Visual Studio - develop Windows apps (Visual Studio Community 2022 17.7.1) [153ms]
• Visual Studio at C:\Program Files\Microsoft Visual Studio\2022\Community
• Visual Studio Community 2022 version 17.7.34009.444
• Windows 10 SDK version 10.0.22621.0
[✓] Android Studio (version 2025.1.1) [32ms]
• Android Studio at C:\Program Files\Android\Android Studio
• Flutter plugin can be installed from:
🔨 https://plugins.jetbrains.com/plugin/9212-flutter
• Dart plugin can be installed from:
🔨 https://plugins.jetbrains.com/plugin/6351-dart
• Java version OpenJDK Runtime Environment (build 21.0.6+-13391695-b895.109)
[✓] Connected device (4 available) [568ms]
• sdk gphone64 x86 64 (mobile) • emulator-5554 • android-x64 • Android 14 (API 34) (emulator)
• Windows (desktop) • windows • windows-x64 • Microsoft Windows [Version 10.0.26100.4351]
• Chrome (web) • chrome • web-javascript • Google Chrome 115.0.5790.110
• Edge (web) • edge • web-javascript • Microsoft Edge 138.0.3351.55
[✓] Network resources [839ms]
• All expected network resources are available.
! Doctor found issues in 1 category.
Version
9.2.0
Steps to Reproduce
flutter build windows --release --obfuscate --split-debug-info=windows/debugInfo
Expected Result
Valid build. Issue doesn't seem to be present on other platforms.
On affected Windows machine sentry_flutter version 8.14.2 works fine.
Actual Result
Nuget.exe not found, trying to download or use cached version.
Nuget.exe not found, trying to download or use cached version.
CMake Error at C:/Program Files/Microsoft Visual Studio/2022/Community/Common7/IDE/CommonExtensions/Microsoft/CMake/CMake/share/cmake-3.26/Modules/FindPackageHandleStandardArgs.cmake:230 (message):
Could NOT find JNI (missing: JAVA_INCLUDE_PATH JAVA_INCLUDE_PATH2 JVM)
Call Stack (most recent call first):
C:/Program Files/Microsoft Visual Studio/2022/Community/Common7/IDE/CommonExtensions/Microsoft/CMake/CMake/share/cmake-3.26/Modules/FindPackageHandleStandardArgs.cmake:600 (_FPHSA_FAILURE_MESSAGE)
C:/Program Files/Microsoft Visual Studio/2022/Community/Common7/IDE/CommonExtensions/Microsoft/CMake/CMake/share/cmake-3.26/Modules/FindJNI.cmake:569 (find_package_handle_standard_args)
flutter/ephemeral/.plugin_symlinks/jni/src/CMakeLists.txt:32 (find_package)
Are you willing to submit a PR?
None
hi do you have java installed on your windows machine?
Hi, I didn't have Java installed, I did download and install JRE. Now in console prompt I get:
java -version
java version "1.8.0_451"
Java(TM) SE Runtime Environment (build 1.8.0_451-b10)
Java HotSpot(TM) Client VM (build 25.451-b10, mixed mode, sharing)
Unfortunately it still didn't resolve the issue.
Could you try to installing a JDK instead
@tomekit After installing JDK, you also might want to create a new environment variable and point it to the jni file folder path.
Sorry for the delay. I've installed JDK and made sure: %JAVA_HOME% is set.
java --version now returns:
java 24.0.2 2025-07-15
Java(TM) SE Runtime Environment (build 24.0.2+12-54)
Java HotSpot(TM) 64-Bit Server VM (build 24.0.2+12-54, mixed mode, sharing)
I am now getting:
C:\Program Files\Microsoft Visual Studio\2022\Community\MSBuild\Microsoft\VC\v170\Microsoft.CppCommon.targets(161,5): error MSB3073: The command "setlocal [C:\data\flutter-drive\build\windows\x64\INSTALL.vcxproj]
C:\Program Files\Microsoft Visual Studio\2022\Community\MSBuild\Microsoft\VC\v170\Microsoft.CppCommon.targets(161,5): error MSB3073: "C:\Program Files\Microsoft Visual Studio\2022\Community\Common7\IDE\CommonExtensions\Microsoft\CMake\CMake\bin\cmake.exe" -DBUILD_TYPE=Debug -P cmake_install.cmake [C:\data\flutter-drive\build\windows\x64\INSTALL.vcxproj]
C:\Program Files\Microsoft Visual Studio\2022\Community\MSBuild\Microsoft\VC\v170\Microsoft.CppCommon.targets(161,5): error MSB3073: if %errorlevel% neq 0 goto :cmEnd [C:\data\flutter-drive\build\windows\x64\INSTALL.vcxproj]
C:\Program Files\Microsoft Visual Studio\2022\Community\MSBuild\Microsoft\VC\v170\Microsoft.CppCommon.targets(161,5): error MSB3073: :cmEnd [C:\data\flutter-drive\build\windows\x64\INSTALL.vcxproj]
C:\Program Files\Microsoft Visual Studio\2022\Community\MSBuild\Microsoft\VC\v170\Microsoft.CppCommon.targets(161,5): error MSB3073: endlocal & call :cmErrorLevel %errorlevel% & goto :cmDone [C:\data\flutter-drive\build\windows\x64\INSTALL.vcxproj]
C:\Program Files\Microsoft Visual Studio\2022\Community\MSBuild\Microsoft\VC\v170\Microsoft.CppCommon.targets(161,5): error MSB3073: :cmErrorLevel [C:\data\flutter-drive\build\windows\x64\INSTALL.vcxproj]
C:\Program Files\Microsoft Visual Studio\2022\Community\MSBuild\Microsoft\VC\v170\Microsoft.CppCommon.targets(161,5): error MSB3073: exit /b %1 [C:\data\flutter-drive\build\windows\x64\INSTALL.vcxproj]
C:\Program Files\Microsoft Visual Studio\2022\Community\MSBuild\Microsoft\VC\v170\Microsoft.CppCommon.targets(161,5): error MSB3073: :cmDone [C:\data\flutter-drive\build\windows\x64\INSTALL.vcxproj]
C:\Program Files\Microsoft Visual Studio\2022\Community\MSBuild\Microsoft\VC\v170\Microsoft.CppCommon.targets(161,5): error MSB3073: if %errorlevel% neq 0 goto :VCEnd [C:\data\flutter-drive\build\windows\x64\INSTALL.vcxproj]
C:\Program Files\Microsoft Visual Studio\2022\Community\MSBuild\Microsoft\VC\v170\Microsoft.CppCommon.targets(161,5): error MSB3073: :VCEnd" exited with code 1. [C:\data\flutter-drive\build\windows\x64\INSTALL.vcxproj]
Error: Build process failed.
Currently using latest: sentry_flutter: 9.4.1, downgrading to: 8.14.2 solve the problem.
After installing JDK, you also might want to create a new environment variable and point it to the jni file folder path.
Thanks @pankaj-nikam Can you let me know what env variable I shall to set and where can I find JNI folder path?
I believe this is now a different issue which the same as https://github.com/getsentry/sentry-dart/issues/2479
can you try this solution: https://github.com/getsentry/sentry-dart/issues/2479#issuecomment-2549492974
if that doesn't work I'd suggest setting the SENTRY_NATIVE_BACKEND environment variable to none which should bypass the set up of the native crash handler
Same here. I can build sentry fine before v9 without Java installed on my Windows machine. @buenaflor could you please explain why we should install Java to develop a Flutter Windows app? Does that mean our users should also install Java to run our app?
@tomekit On my machine, I found jni.h at "C:\Program Files\Microsoft\jdk-17.0.16.8-hotspot\include\jni.h" I added the folder "C:\Program Files\Microsoft\jdk-17.0.16.8-hotspot\include" to the PATH environment variable and it compiled.
@mgenware we are using JNI starting from v9 for our Android support and the JNI plugin on Windows compiles dartjni.dll which is linked against jvm.dll.
Currently I don't think there is a solution in which we can prevent this other than to fork the jni pkg and stub the windows impl.
@vaind wdyt? is there anything we can do here?
Also would like to know if this will now require users to have jdk installed
If I understand correctly, what's happening is building windows requires JNI libraries even though we don't use JNI on Windows, right? If so, this is an issue of the flutter plugin system not allowing us to specify which platforms we actually need. There's a tracking issue upstream (if you check the later comments in there you see discussions addressing this): https://github.com/flutter/flutter/issues/81650 - but it doesn't look like anyone is actively preparing any changes at the moment.
I'm not sure if there's anything that can be done on sentry-flutter SDK end though :/
Also would like to know if this will now require users to have jdk installed
most likely not since we never invoke any JNI code in runtime for any target other than Android - it won't try to load the dartjni.dll and won't try to load and initializes the JVM unless we'd use Jni.spawn().
I'll prepare a sentry-docs troubleshooting entry for that
@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?
@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.
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.
Is there a tracking issue?
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.
Is there a tracking issue?
Will be done as part of this umbrella issue: https://github.com/dart-lang/native/issues/1023
Another thing I can do in the meantime is add a warning in the CMakeLists.txt so if JNI is not found, then it just doesn't build libdartjni and prints a warning and build will be successful.
Another thing I can do in the meantime is add a warning in the CMakeLists.txt so if JNI is not found, then it just doesn't build libdartjni and prints a warning and build will be successful.
sounds good
Another thing I can do in the meantime is add a warning in the
CMakeLists.txtso ifJNIis not found, then it just doesn't buildlibdartjniand prints a warning and build will be successful.
This would be helpful. I'd prefer to not have to set up java in a windows build pipeline if it's not a necessary requirement