Build error after adding new dependencies – Gradle issue

Hey Flutter Community! :wave:

I’m facing a frustrating issue while trying to run my Flutter project on an Android emulator. The error occurs after adding any new dependencies to the pubspec.yaml file.



Launching lib\main.dart on sdk gphone64 x86 64 in debug mode...
Running Gradle task 'assembleDebug'...

FAILURE: Build failed with an exception.

* What went wrong:
Could not determine the dependencies of task ':path_provider_android:compileDebugJavaWithJavac'.
> Could not determine the dependencies of null.
   > Cannot query the value of this provider because it has no value available.

BUILD FAILED in 6s
Error: Gradle task assembleDebug failed with exit code 1

The strange part is that I’m not using the path_provider package in my project, yet this error still occurs every time I add a new dependency. I’ve tried running flutter clean and flutter pub get, but the issue persists.

Has anyone encountered this error before or knows a possible solution? Any help would be greatly appreciated!

I haven’t seen this specific error. It is possible that there is a transitory dependency of one of your top level dependencies that is pulling in that library. If you run flutter pub deps that will print a dependency graph for your project.

Frequently errors like this are caused by changes needed in the gradle.build file. You could create a new project from scratch in another directory and compare the gradle.build files with yours and see differences. Maybe a compile version, min sdk version, or target sdk version has moved on you over time. This always gets me. Good luck, I hope this helps.

Check AGP with java version?