Chris G.
Chris G.

Reputation: 25954

Flutter/ Android Studio: error: Target of URI doesn't exist: 'package:flutter_gen/gen_l10n/app_localizations.dart'

Android Studio Bumblebee

| 2021.1.1 Patch 2
Build #AI-211.7628.21.2111.8193401, built on February 17, 2022
Runtime version: 11.0.11+0-b60-7772763 aarch64
VM: OpenJDK 64-Bit Server VM by JetBrains s.r.o.
macOS 12.3
GC: G1 Young Generation, G1 Old Generation
Memory: 1280M
Cores: 8
Registry: external.system.auto.import.disabled=true
Non-Bundled Plugins: com.bloc.intellij_generator_plugin (3.3.0), Dart (211.7811), org.jetbrains.kotlin (211-1.6.10-release-923-AS7442.40), io.flutter (65.2.2), org.intellij.plugins.markdown (211.7142.37)

flutter --version

Flutter 2.10.4 • channel stable • https://github.com/flutter/flutter.git
Framework • revision c860cba910 (10 days ago) • 2022-03-25 00:23:12 -0500
Engine • revision 57d3bac3dd
Tools • Dart 2.16.2 • DevTools 2.9.2

Localization

pubspec.yaml

...
  flutter_gen: ^4.1.6
  flutter_localizations:
    sdk: flutter
  intl: ^0.17.0


flutter:
  uses-material-design: true
  generate: true
...

l10n.yaml(in project root):

arb-dir: lib/l10n/arb
template-arb-file: app_en.arb
output-localization-file: app_localizations.dart
nullable-getter: false

Trying to import:

import 'package:flutter_gen/gen_l10n/app_localizations.dart';

But get error:

error: Target of URI doesn't exist: 'package:flutter_gen/gen_l10n/app_localizations.dart'

Non of the following SO worked:

one

two

Upvotes: 0

Views: 1670

Answers (1)

shraddha patel
shraddha patel

Reputation: 778

If you have the intl plugin in your code editor (Android Studio) then you should have this generated folder (lib/generated/l10n.dart).

Run this command in your terminal ' flutter pub run intl_utils:generate'

At check pubspec.yaml file,

    dependencies:
    
    flutter:
        sdk: flutter
    flutter_localizations:
        sdk: flutter
    intl_utils: ^2.6.1

flutter_intl:
  enabled: true

Then after it will be work, please try it.

Upvotes: 1

Related Questions