Junaid Hassan Final
Junaid Hassan Final

Reputation: 365

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

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

Upvotes: 10

Views: 18489

Answers (7)

umair shah
umair shah

Reputation: 9

I was facing this issue because I have changed my Firebase account. I run the Firebase logout and the Firebase login command, after that, I was configuring a project but it was giving me this error. So I run the pub activate command which we run after the firebase CLI Install. Just run the below command, and it will fix it if you face the same issue.

dart pub global activate flutterfire_cli

Upvotes: 0

jakobleck
jakobleck

Reputation: 179

For me this problem appeared while trying to run an app on an iOS device (first appeared after adding a package, but persisted after removing the package dependency). I tried many things, but what finally resolved it was deleting the contents of the Xcode DerivedData directory. (I.e. Xcode -> Settings -> Locations, open DerivedData in Finder and delete its contents.)

Upvotes: 0

Oliver Dixon
Oliver Dixon

Reputation: 7424

dart pub global activate rps (or some other package)

After each update it invalids these packages.

Upvotes: 5

Luis Bastos
Luis Bastos

Reputation: 1

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

dart pub global activate pana

Upvotes: 0

Manan Koyawala
Manan Koyawala

Reputation: 1

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

Upvotes: 0

CoderBlue
CoderBlue

Reputation: 995

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.

Upvotes: 1

Junaid Hassan Final
Junaid Hassan Final

Reputation: 365

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.

Upvotes: 10

Related Questions