flutter,Could not resolve project :path_provider_macos...

如题,报错信息如下:

flutter,Could not resolve project :path_provider_macos...

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.
   > Could not resolve project :path_provider_linux.
     Required by:
         project :path_provider
      > Unable to find a matching configuration of project :path_provider_linux:
          - None of the consumable configurations have attributes.

其实主要看上面红色的报错信息,是说加载到了linux库和macos的库。这个问题在flutter开发中很常见,运行着好好的,突然就报这个错。flutter clean 一般是没有用的。解决方案如下:

1.找到这个库path_provider的文件所在的位置:

flutter,Could not resolve project :path_provider_macos...flutter,Could not resolve project :path_provider_macos...

flutter,Could not resolve project :path_provider_macos...

2.删除掉文件夹下所有path_provider的相关库,如上图,4个库全部删除;

3.回到Android Studio中刷新,再get ,dart packag列表会发生变化;

4.再运行,如果运行还是报其他的库xxx_macos,xxx_linux,则同样执行以上操作,直接删除。

把所有的报这种错误(xxx_macos,xxx_linux)的库文件删除干净,再get,就行了。

 

注意,如果只是删除Android Studio中的这些库是没有效果的,因为Android Studio中显示的只是这些库的索引,删了索引,库文件没有删除是没有效果的,切记要进入到文件夹里面去删除对应的库才有效果