7

I am currently learning flutter. Suddenly when i try to run my project i got the error that says "D:..\android.dart_tool\package_config.json does not exist. Did you run this command from the same directory as your pubspec.yaml file?". I have checked the directory and it is correct. And there is no package_config.json when i go to the directory stated. Can someone tell me how to fix this? Or how to recreate the json file? Thank you in advance.

enter image description here

    Microsoft Windows [Version 10.0.19042.906]
(c) Microsoft Corporation. All rights reserved.

D:\FlutterProject\wndr2u>flutter run
Using hardware rendering with device AOSP on IA Emulator. If you notice graphics artifacts, consider enabling software rendering with "--enable-software-rendering".
Launching lib\main.dart on AOSP on IA Emulator in debug mode...
D:\FlutterProject\wndr2u\android\.dart_tool\package_config.json does not exist.
Did you run this command from the same directory as your pubspec.yaml file?


FAILURE: Build failed with an exception.

* Where:
Script 'D:\flutter\packages\flutter_tools\gradle\flutter.gradle' line: 1035

* What went wrong:
Execution failed for task ':app:compileFlutterBuildDebug'.
> Process 'command 'D:\flutter\bin\flutter.bat'' finished with non-zero exit value 1

* 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

BUILD FAILED in 1s
Running Gradle task 'assembleDebug'...
Running Gradle task 'assembleDebug'... Done                      2,703ms
Exception: Gradle task assembleDebug failed with exit code 1
MRu
  • 1,225
  • 7
  • 20
  • 44

2 Answers2

10
  1. Flutter clean
  2. Flutter pub get
  3. Open the project in the android module
  4. Generate APK or bundle
Hardik Hirpara
  • 2,594
  • 20
  • 34
4

Run Tools > Flutter > Pub Get

It worked for me

Ismaeel Sherif
  • 555
  • 7
  • 15