解决Could not create task …this and base files have different roots

直接编译运行Flutter项目是没问题的,但是单独打开Android项目进行编译却报错了。

Multiple build operations failed. Could not create task ':path_provider_android:generateDebugUnitTestConfig'. Could not create task ':shared_preferences_android:generateDebugUnitTestConfig'. Could not create task ':url_launcher_android:generateDebugUnitTestConfig'. Could not create task ':video_player_android:generateDebugUnitTestConfig'. Could not create task ':path_provider_android:generateDebugUnitTestConfig'. this and base files have different roots: D:\XXXXXX\build\path_provider_android and C:\Users\xxxx\AppData\Local\Pub\Cache\hosted\pub.dev\path_provider_android-2.2.10\android.

解决方法是:

  1. 运行flutter clean
  2. 在不执行flutter pub get的前提下,立即去执行Gradle sync
  3. 编译Flutter项目

留下评论

您的邮箱地址不会被公开。 必填项已用 * 标注