Maaz Zindani

Loading the index…

↑↓ move↵ openesc close4791 pages
Flutter and app store releases

Windows antivirus stops a Flutter build with OS error 225

Your error

Target kernel_snapshot_program failed: ProcessException: Operation did not complete successfully because the file contains a virus or potentially unwanted software.2 more lines it can show

Fix it fast

Most common cause, 1 of 3

Defender quarantined a Dart or Flutter SDK file

Restore the file from Windows Security, Virus and threat protection, Protection history, or with MpCmdRun.

Fix
MpCmdRun.exe -Restore -Name <filename>

# PowerShell as administrator; adjust to your SDK path
Add-MpPreference -ExclusionPath 'C:\dev\flutter'
Did this fix it?
Full steps for this cause: check, fix, verify

Short answer

The file contains a virus or potentially unwanted software message is Windows error 225: antivirus, usually Microsoft Defender, blocked or quarantined a file Flutter needs, nearly always a false positive. Find the flagged path in Protection history, restore it, and exclude the Flutter SDK, the project and the pub cache. Applies to Flutter 3.50 on Windows 10 and 11.

  • Applies to Flutter 3.50.1 (Dart 3.14) on Windows 10 and 11, Microsoft Defender Antivirus, Android and Windows desktop builds
  • Updated
  • By Maaz Zindani, Senior Software Engineer

Which cause do you have?

Ask Defender what it caught and where. The file path decides the cause: a path under flutter\bin\cache is cause 1, a path in your project or the pub cache is cause 2, and an empty list while the error stays points to cause 3. Run in PowerShell as administrator.

Run this first
Get-MpThreatDetection

Then find the line you see in this list and open its fix:

  1. 1Defender quarantined a Dart or Flutter SDK fileThe error names a file under flutter\bin\cache, such as dart-sdk\bin\dartaotruntime.exe, and Defender lists a detection for that path
  2. 2A file in the project build output or the pub cache was flaggedThe flagged path sits under your app's build or .dart_tool folder, or under %LOCALAPPDATA%\Pub\Cache
  3. 3A third-party antivirus, not Defender, is blocking the fileGet-MpThreatDetection lists nothing new, yet error 225 keeps coming back; McAfee, Bitdefender or a company endpoint agent is installed

What does the error look like?

  • Target kernel_snapshot_program failed: ProcessException: Operation did not complete successfully because the file contains a virus or potentially unwanted software.
  • ProcessException: Operation did not complete successfully because the file contains a virus or potentially unwanted software. Command: C:\dev\flutter\bin\cache\dart-sdk\bin\dartaotruntime.exe, OS error code: 225
  • FileSystemException: Cannot open file, OS Error: Operation did not complete successfully because the file contains a virus or potentially unwanted software., errno = 225

Cause 1 of 3

Defender quarantined a Dart or Flutter SDK file

You seeThe error names a file under flutter\bin\cache, such as dart-sdk\bin\dartaotruntime.exe, and Defender lists a detection for that path

Check

Error 225 with a path inside the Flutter SDK means Windows refused to run or open an SDK file because antivirus flagged it. Microsoft documents code 225 as ERROR_VIRUS_INFECTED. Flutter maintainers treat these reports as antivirus false positives and point to the allowlist advice in issue 61997.

Check
# elevated Command Prompt, from the Defender platform folder
MpCmdRun.exe -Restore -ListAll

Fix

Restore the file from Windows Security, Virus and threat protection, Protection history, or with MpCmdRun. Then add the Flutter SDK folder to the Defender exclusions so the next scan does not take it again.

Fix
MpCmdRun.exe -Restore -Name <filename>

# PowerShell as administrator; adjust to your SDK path
Add-MpPreference -ExclusionPath 'C:\dev\flutter'

Verify

flutter doctor runs without errors and the build passes the kernel snapshot step.

Verify
flutter doctor -v

Confirmed by learn.microsoft.com

Did this fix it?

Cause 2 of 3

A file in the project build output or the pub cache was flagged

You seeThe flagged path sits under your app's build or .dart_tool folder, or under %LOCALAPPDATA%\Pub\Cache

Check

Freshly written build files and downloaded packages trip antivirus too. McAfee once quarantined the debug .exe of a project only because of its name, and a Flutter maintainer answered that it was a false positive needing an allowlist entry. Pub keeps packages in %LOCALAPPDATA%\Pub\Cache on Windows unless PUB_CACHE points elsewhere.

Check
echo %LOCALAPPDATA%\Pub\Cache

Fix

Exclude the project folder and the pub cache, then let Flutter recreate the generated files. flutter clean deletes build/ and .dart_tool/, so the next build writes them fresh.

Fix
Add-MpPreference -ExclusionPath 'C:\src\my_app'
Add-MpPreference -ExclusionPath "$env:LOCALAPPDATA\Pub\Cache"

flutter clean
flutter pub get
flutter run

Verify

The app builds and starts, and Get-MpThreatDetection shows no new entry for the project or the cache.

Verify
Get-MpThreatDetection

Confirmed by github.com

Did this fix it?

Cause 3 of 3

A third-party antivirus, not Defender, is blocking the file

You seeGet-MpThreatDetection lists nothing new, yet error 225 keeps coming back; McAfee, Bitdefender or a company endpoint agent is installed

Check

Defender exclusions do nothing when another product does the blocking; Microsoft's compatibility guide says AMRunningMode reads Passive or similar when Defender is not the main antivirus. Flutter's own tracking issue collects cases from several vendors, including Bitdefender flagging files as ransomware and corporate blocklists that stop single files.

Check
Get-MpComputerStatus | Select-Object AMRunningMode, RealTimeProtectionEnabled

Fix

Open that product's quarantine, restore the Flutter file, and add the same three folders to its exclusion list. On a managed work PC, ask IT to allow the Flutter SDK, your project folder and the pub cache.

Fix
# folders to hand to the antivirus vendor or IT team
C:\dev\flutter
C:\src\my_app
%LOCALAPPDATA%\Pub\Cache

Verify

A full flutter build windows or flutter build apk finishes without error 225.

Verify
flutter build apk --debug

Confirmed by github.com

Did this fix it?

How do I stop it coming back?

  • Add the SDK, project and pub cache exclusions on a new Windows machine before the first flutter doctor, so nothing gets quarantined mid-download.
  • Keep Flutter projects in one parent folder such as C:\src and exclude that folder once, rather than adding every new project.
  • Exclude only those development folders, never a whole drive; Microsoft notes that an excluded folder is skipped by both scheduled and real-time scans.

Sources

How was this page made?

I drafted this page with AI assistance from the official documents listed under Sources. Every cause above names the document that confirms it. I have not reproduced this fix on a machine of my own yet, so read it as documented guidance, not a test report. Found a mistake? Tell me.

Which stack is behind this page?

Projects of mine on the same stack: TaxiDex, Qist Bazaar, SessionBird.

Next step

Want this handled for good?

I look after servers, apps and releases end to end. Tell me what keeps breaking.