Flutter VSCode : Debug error:Could not create service of type FileHasher using BuildSessionServices.createFileHasher()

Issue

Trying to start programming Dart in Flutter. I wanted to work with VSCode instead of Android Studio, but when debug session starts I get the following problems.

I tried everything here in this link such as deleting the caches, deleting lock file, kill PID Task in cmd, but nothing works.

However, I’m able to run the test app in Android Studio, but still, I wanted to learn via VSCode. It will be great if you can share any suggestion that might help 🙂

Thanks!

FAILURE: Build failed with an exception.

* What went wrong:
Gradle could not start your build.
> Could not create service of type FileHasher using BuildSessionServices.createFileHasher().
   > Unexpected lock protocol found in lock file. Expected 3, found 0.

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

Flutter SDK: windows 1.17.1 (from the website)
Android Studio: 3.6.3

Solution

Able to solve my own problem. Apparently, when I first sync the demo app in VSCode, it started to download package from gradle 5.62, whereas 6.4 available in my machine. Which then I changed the setting and distributionUrl thingy to that version 6.4 . And when I started to run it, that error stated in the question surfaced.

What I did was:

  1. Go to project level .gradle file (app> android> .gradle)

  2. Delete the file of gralde of the other version

  3. Go to the gradle folder of the 6.4 version, delete the lock file in caches/filehashes
  4. restart

Answered By – mocha234

Answer Checked By – Katrina (FlutterFixes Volunteer)

Leave a Reply

Your email address will not be published. Required fields are marked *