flutterbuild-runner

Flutter Invalid argument(s): Missing Library (build_runner failure)


I'm using Flutter auto_route_generator package (which is based on built_runner) to generate auto_routes.

When I run flutter packages pub run build_runner build I'm getting the above exception:

[SEVERE] auto_route_generator:autoRouteGenerator on lib/main_staging.dart (cached):

Invalid argument(s): Missing library: package:tenant_app/app/app.dart

I encountered this issue after upgrading the Flutter version from 3.0.5 to 3.3.1

Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, 3.3.1, on macOS 12.5.1 21G83 darwin-x64, locale en-IL)
[✓] Android toolchain - develop for Android devices (Android SDK version 33.0.0)
[✓] Xcode - develop for iOS and macOS (Xcode 13.4.1)
[✓] Chrome - develop for the web
[✓] Android Studio (version 2021.2)
[✓] VS Code (version 1.70.2)
[✓] Connected device (3 available)
[✓] HTTP Host Availability

I tried to run the build_runner using --delete-conflicting-outputs but it didn't help

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

What is the problem? Why the build_runner is failing?


Solution

  • Issue solved

    Running the following tasks solved my issue:

    1. flutter clean
    2. flutter pub cache repair
    3. flutter pub get
    4. flutter packages pub run build_runner build --delete-conflicting-outputs

    It seems that there was an issue with the cached packages after upgrading the Flutter version. Still, don't know what exactly happened.