4
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

FlutterでJSONをシリアル化するときにbuild_runnerがファイルを生成しない時

Posted at

日本語で書かれた記事がないので備忘録として記述しておきます。

json_annotationjson_serializableのコードジェネレーターライブラリを使ってJSONのデコード(エンコード)を行っている時に出るエラーの対処法

[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-outputs`. 
The outputs are: lib/××××/my_api_service.g.dart
lib/××××/api_service.g.dart
lib/××××/test_api_service.g.dart

上記の様な「コンフリクトしてて生成できないよ!」と言うエラーがたまに(結構な頻度で)出ますが、書いてある通りに--delete-conflicting-outputsのオプションをつけてコマンドを叩けば、一度、〇〇〇〇.g.dartを削除して再生成してくれます。

うまくいかない時は一度削除するとすんなり生成されるっぽい。
ファイル自体を物理的に削除しても生成されますが、色々とややこしくなると怖いのでコマンドでやった方が安全だと思います。
コマンドはこちら

flutter packages pub run build_runner build --delete-conflicting-outputs

参考文献

4
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
4
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?