使用path_provider時,運行時可能遇到以下錯誤
FAILURE: Build failed with an exception.
* What went wrong:
Could not determine the dependencies of task ':path_provider:compileDebugAidl'.
> Could not resolve all task dependencies for configuration ':path_provider:debugCompileClasspath'.
> Could not resolve project :path_provider_macos.
Required by:
project :path_provider
> Unable to find a matching configuration of project :path_provider_macos:
- None of the consumable configurations have attributes.
* 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 2s
Finished with error: Gradle task assembleDebug_QATDebug failed with exit code 1
解決方法
有以下兩種方法
- 進入Flutter SDK文件夾,找到.pub-cache\hosted\pub.dartlang.org文件夾,如果存在 path_provider_macos文件夾,刪除即可。如果沒有,找到.pub-cache\hosted\pub.flutter-io.cn文件夾,刪除path_provider_macos。
- 刪除Flutter SDK,重新下載最新的SDK。再次運行。