Can't load Kernel binary: Invalid SDK hash in Flutter
Asked Answered
D

5

10

Whenever I try to run a dart tool like Dart Migrate I get the following error and I am unable to run that tool. Is there a way to solve this problem or I have to reinstall Flutter? enter image description here

Btw every thing is okay with Flutter Doctor

enter image description here

Dejesus answered 13/4, 2021 at 12:0 Comment(0)
D
10

After a lot of effort and wasting a lot of time on this issue I have been able to solve this problem. I have installed dart-sdk separately in the past and place the path of that dart-sdk at the top (before flutter one) in environment variables PATH. So I deleted that old dart-sdk path and deleted the respective folder this solved my problem.

Dejesus answered 13/4, 2021 at 15:10 Comment(0)
R
5

dart pub global activate rps (or some other package)

After each update it invalids these packages.

Rosenkrantz answered 10/3, 2023 at 9:25 Comment(1)
Actually this was the solution in my case where I upgraded Flutter and running Melos was yielding this error. Thanks. ;)Gametogenesis
K
1

In VS Code, if you get "Can't Load Kernel binary: Invalid SDK Hash" in Flutter or Dart, update dart.sdkPath setting

If you get this in VS Code, in addition to re-downloading the dart-sdk, make sure the "dart.sdkPath" setting in user/workspace settings is pointing to the new SDK. In my case, even though I had it in my path as in Junaid's answer, VS Code was still looking to the old dart-sdk folder and giving me the kernel hash error. I updated the dart.sdkPath to the correct path and restarted VS Code:

For example, in Windows:

  1. Download dart sdk

  2. Unzip it to c:\tools\dart-sdk or any other folder (make sure you rename or delete the existing dart-sdk folder)

  3. ctrl-shift-p, type 'user settings (JSON)', open the json settings, and add:

  "dart.sdkPath": "C:\\tools\\dart-sdk",

  1. Update your system PATH environmental variable to point to the new dart-sdk and delete the reference to the old location.

  2. Restart VS Code.

Klinger answered 15/9, 2022 at 17:32 Comment(0)
C
0

Note that Instead of This "dart.sdkPath": "D:\Dart\dart-sdk\bin" work well for me. path should be included '\bin' also. It work for me

Cleveland answered 4/12, 2022 at 4:27 Comment(0)
D
0

For me, trying to run pana and seeing this error, was just a metter or reinstalling it:

dart pub global activate pana
Deck answered 7/3, 2023 at 11:20 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.