build icon indicating copy to clipboard operation
build copied to clipboard

Random "Invalid argument(s): Missing library [...]" when run build_runner

Open bummsa opened this issue 11 months ago • 29 comments

Hi there,

I'm having an issue building my Flutter app for iOS for about every 2-3 builds during code generation and it occurs randomly and I can't recognize a pattern.

My project structure looks like this:

my_app --> shared_project_1 --> shared_project_2 --> application_project

I run the build_runner in all projects and it fails randomly in any of the 3 subprojects and any dto's I have in the projects with the following error: Invalid argument(s): Missing library: package:shared_project_1/shared/dto/fruit_dto.dart Libraries: [dart:async, dart:collection, dart:convert, dart:core, ...]

and the fruit_dto looks like this:

`import ...;

part 'fruit_dto.g.dart';

@JsonSerializable() class FruitDto extends Dto { final String name; final String shape; final String color;

FruitDto({ int? id, int? noi, super.entityTag, required this.name, required this.shape, this.color = '', }) : super(containerId: id, noI: noi);

static FruitDto fromJson(Map<String, dynamic> json) => _$FruitDtoFromJson(json); @override Map<String, dynamic> toJson() => _$FruitDtoToJson(this); }`

It lists like all the classes I have in my project, including some Flutter packages, such as "package:flutter/src/foundation/print.dart".

flutter sdk: 3.19.3 (reproducible with 3.16.x as well) build_runner: 2.4.8 json_serializable: 6.7.1

Mac Mini with M2 Pro: 14.2.1

Does anyone have any ideas on how to fix the issue?

Thanks and best regards bummsa

bummsa avatar Mar 19 '24 10:03 bummsa