Flutter雜症( flutter packages pub run build_runner build )

報錯日誌

[INFO] Checking for unexpected pre-existing outputs....
[INFO] Found 14 declared outputs which already exist on disk. This is likely because the`.dart_tool/build` folder was deleted, or you are submitting generated files to your source repository.
[SEVERE] Conflicting outputs were detected and the build is unable to prompt for permission to remove them. These outputs must be removed manually or the build can be run with `--delete-conflicting-o
utputs`. The outputs are: lib/data/http/rsp/BaseRsp.g.dart

[INFO] Generating build script...
[INFO] Generating build script completed, took 246ms
[SEVERE] Nothing can be built, yet a build was requested.
pub finished with exit code 78
複製代碼

引起的過程

這個問題出現的挺巧的,項目給的工時不長,週六回家以後用本身電腦從git倉庫上Clone了一份代碼,運行沒有問題。可是在用flutter packages pub run build_runner build生成xxxx.g.dart的時候問題出來了。日誌如上。git

引起的緣由

緣由其實日誌也說明了。我在提交代碼的時候把flutter packages pub run build_runner build生成的xxxx.g.dart也提了上去。運行flutter packages pub run build_runner build不光生成了xxxx.g.dart。同時還成了一個dart_tool/build目錄,入過程所說的只運行app是沒有問題的,以前xxxx.g.dart仍是可用的。可是再生成新的xxxx.g.dart由於缺乏以前生成dart_tool/build目下的文件就會報錯。app

because the`.dart_tool/build` folder was deleted, or you are submitting generated files to your source repository
複製代碼

解決

命令行運行:ui

//清除以前生成的文件,若是直接運行下面的不行。能夠先嚐試運行這個
 flutter packages pub run build_runner clean
//能夠直接運行這個
 flutter packages pub run build_runner build --delete-conflicting-outputs
複製代碼

固然解決問題的根本方法仍是提代碼的時候不要將生成的文件也提交到遠程倉庫spa

相關文章
相關標籤/搜索