⚡
flutter ビルドエラー「Target of URI doesn't exist...app_localizations...」と対処法
エラー
Target of URI doesn't exist: 'package:flutter_gen/gen_l10n/app_localizations.dart'.
Try creating the file referenced by the URI, or try using a URI for a file that does exist.
対処方法
- pubspec.yamlを確認 ※generate: trueのプロジェクトは対象
pubspec.yaml
flutter:
generate: true
- l10n.yamlの修正
l10n.yaml
+ synthetic-package: false
arb-dir: lib/l10n # .arbファイルがあるディレクトリ
- output-localization-file: app_localizations.dart
+ output-dir: lib/generated/i18n
- flutter pub get実行
flutter pub get
- インポートの修正
- import 'package:flutter_gen/gen_l10n/app_localizations.dart';
+ import 'package:ensembles_app/generated/i18n/app_localizations.dart';
- flutter configの実行(任意)
flutter config --explicit-package-dependencies
Discussion