인프런 영문 브랜드 로고
인프런 영문 브랜드 로고

인프런 커뮤니티 질문&답변

mhlee님의 프로필 이미지

작성한 질문수

Flutter 중급 1편 - 클린 아키텍처

22 노트 모델 클래스, NoteRepository 작성

This is likely caused by a misconfigured builder definition. 오류 해결 방법

작성

·

176

1

버전을 최신으로 마춰도 에러나는 경우 해결방법 공유합니다.

 

일단 선생님 환경은 현재 할수 없으므로 최신버전으로 마춰주시고 최신버전 의존성도 전부 완료되었는데도 안되는 경우는 아래 부분을 해보세요.

 

환경 샘플 플러터 3버전

  • dependencies:

    • provider: ^6.1.4

    • sqflite: ^2.0.0+4

    • json_annotation: ^4.9.0 →json 직렬화

    • freezed_annotation: ^3.0.0 →불변 코드 생성

  • dev_dependencies:

    • json_serializable: ^6.9.3 → JSON 직렬화 및 역직렬화 자동 생성

    • freezed: ^3.0.6 → 불변 객체 생성

    • build_runner: ^2.4.15 → 코드 생성 도구 생성 패키지 실행

 

  • 첫번째 방법

1.컴퓨터 off on

2.flutter clean

3.flutter pub run build_runner build

4.flutter pub run build_runner build --delete-conflicting-outputs

4단계까지 안되면...

5.신규 프로젝트 생성...

 

  • 2번째 방법

  • dependencies:

    • provider: ^6.1.4

    • sqflite: ^2.0.0+4

    • json_annotation: ^4.9.0 →json 직렬화

    • freezed_annotation: ^3.0.0 →불변 코드 생성

    • analyzer: ^6.0.0

  • dev_dependencies:

    • json_serializable: ^6.9.3 → JSON 직렬화 및 역직렬화 자동 생성

    • freezed: ^3.0.6 → 불변 객체 생성

    • build_runner: ^2.4.15 → 코드 생성 도구 생성 패키지 실행

 

낮은 버전으로 진행 후에 높은버전으로 진행했을때

json_serializable에서 analyzer가 삭제가 제대로 안되서 문제가 되는 경우가 있는것 같습니다.

 

억지로 analyzer 맞추고 진행하고 되었을대

analyzer을 제거하면 잘되었습니다.

 

flutter 환경 세팅은 어렵군요...

시간 낭비 안되도록 공유해봅니다.

 

 

에러내용:

 

C:\project\flutter_cleancode\flutter_note_app> flutter pub run build_runner build

Deprecated. Use dart run instead.

[INFO] Generating build script completed, took 326ms

[WARNING] /C:/Users/karyo/AppData/Local/Pub/Cache/hosted/pub.dev/json_serializable-6.9.4/lib/src/field_helpers.dart:84:52: Error: The argument type 'ClassElement' can't be assigned to the parameter type 'InterfaceElementImpl'.

- 'ClassElement' is from 'package:analyzer/dart/element/element.dart' ('/C:/Users/karyo/AppData/Local/Pub/Cache/hosted/pub.dev/analyzer-7.4.0/lib/dart/element/element.dart').

- 'InterfaceElementImpl' is from 'package:analyzer/src/dart/element/element.dart' ('/C:/Users/karyo/AppData/Local/Pub/Cache/hosted/pub.dev/analyzer-7.4.0/lib/src/dart/element/element.dart').

for (final v in manager.getInheritedConcreteMap2(element).values) {

^

/C:/Users/karyo/AppData/Local/Pub/Cache/hosted/pub.dev/json_serializable-6.9.4/lib/src/field_helpers.dart:90:43: Error: The getter 'isGetter' isn't defined for the class 'ExecutableElementOrMember'.

- 'ExecutableElementOrMember' is from 'package:analyzer/src/dart/element/element.dart' ('/C:/Users/karyo/AppData/Local/Pub/Cache/hosted/pub.dev/analyzer-7.4.0/lib/src/dart/element/element.dart').

Try correcting the name to the name of an existing getter, or defining a getter or field named 'isGetter'.

if (v is PropertyAccessorElement && v.isGetter) {

^^^^^^^^

/C:/Users/karyo/AppData/Local/Pub/Cache/hosted/pub.dev/json_serializable-6.9.4/lib/src/field_helpers.dart:91:16: Error: The getter 'variable2' isn't defined for the class 'ExecutableElementOrMember'.

- 'ExecutableElementOrMember' is from 'package:analyzer/src/dart/element/element.dart' ('/C:/Users/karyo/AppData/Local/Pub/Cache/hosted/pub.dev/analyzer-7.4.0/lib/src/dart/element/element.dart').

Try correcting the name to the name of an existing getter, or defining a getter or field named 'variable2'.

assert(v.variable2 is FieldElement);

^^^^^^^^^

/C:/Users/karyo/AppData/Local/Pub/Cache/hosted/pub.dev/json_serializable-6.9.4/lib/src/field_helpers.dart:92:26: Error: The getter 'variable2' isn't defined for the class 'ExecutableElementOrMember'.

- 'ExecutableElementOrMember' is from 'package:analyzer/src/dart/element/element.dart' ('/C:/Users/karyo/AppData/Local/Pub/Cache/hosted/pub.dev/analyzer-7.4.0/lib/src/dart/element/element.dart').

Try correcting the name to the name of an existing getter, or defining a getter or field named 'variable2'.

final variable = v.variable2 as FieldElement;

^^^^^^^^^

/C:/Users/karyo/AppData/Local/Pub/Cache/hosted/pub.dev/json_serializable-6.9.4/lib/src/decode_helper.dart:65:23: Error: The getter 'augmented' isn't defined for the class 'ClassElement'.

- 'ClassElement' is from 'package:analyzer/dart/element/element.dart' ('/C:/Users/karyo/AppData/Local/Pub/Cache/hosted/pub.dev/analyzer-7.4.0/lib/dart/element/element.dart').

Try correcting the name to the name of an existing getter, or defining a getter or field named 'augmented'.

element.augmented

^^^^^^^^^

[INFO] Precompiling build script... completed, took 880ms

[SEVERE] Failed to precompile build script .dart_tool/build/entrypoint/build.dart.

This is likely caused by a misconfigured builder definition.

답변 3

0

오준석님의 프로필 이미지
오준석
지식공유자

저는 다음 명령으로도 해결되었습니다. 참고하세요.
flutter pub upgrade && flutter clean && flutter pub cache clean

0

오준석님의 프로필 이미지
오준석
지식공유자

공유 감사합니다.

저도 시간될 때 최신 라이브러리에 맞게 작업해서 업데이트 할게요.

0

인프런 AI 인턴님의 프로필 이미지

안녕하세요, 인프런 AI 인턴입니다. mhlee님께서 공유해주신 방법은 플러터 환경에서 발생할 수 있는 오류들을 해결하는 데 유용할 수 있습니다. 이와 관련된 문제는 주로 의존성 버전 충돌에서 비롯되며, 시스템 환경이나 캐시 파일과의 충돌이 발생할 때도 빈번히 나타납니다.

문제 요약:
1. 오류: “This is likely caused by a misconfigured builder definition.“라는 메시지는 주로 build_runner의 설정 파일이나 의존성 버전 문제 때문에 발생합니다. 주로 json_serializable과 analyzer 패키지 간의 버전 불일치로 인해 발생할 수 있습니다.

  1. 해결 방법:
    • 최신 버전 의존성 설정: 최신 버전의 의존성을 설정하여 문제가 되는 구성을 해결합니다.
    • 캐시 클리어: flutter clean 명령어를 통해 프로젝트의 캐시 데이터를 클리어하고, flutter pub run build_runner build 실행해서 새로 빌드합니다.
    • pubspec.yaml 업데이트: 의존성을 강화하기 위해 관련 라이브러리의 최신 버전으로 업데이트합니다.

추가적으로 시도해 볼 수 있는 사항:
- 버전 매칭: 각 패키지의 의존성을 최신으로 유지하는 것도 중요합니다. pubspec.yaml 파일을 최신 패키지 버전에 맞게 업데이트하고, 필요 시에 누락된 의존성을 추가합니다.

  • 필요 시 신규 프로젝트 생성: 종종 환경 설정 자체가 문제의 원인일 수 있으므로, 거듭하여 같은 문제가 발생한다면 새 프로젝트를 생성하여 해결하는 방법도 고려해 볼 수 있습니다.

질문자님의 환경에서 제공해 주신 방법이 다른 개발자분들께도 문제 해결의 실마리가 될 수 있습니다. 각 패키지가 제공하는 공식 문서도 지속적으로 참고하시고, 커뮤니티의 도움도 받아보세요.

참고로 유사한 사례를 논의한 기존 질문 링크는 다음과 같습니다:
- g.dart 파일이 생성이 안됩니다.: 이 게시물에서 오타로 인한 문제 해결 방법을 제시하며, 사용자 경험을 바탕으로한 접근을 공유합니다.

저는 질문자님의 이해를 돕고자 지식공유자님의 기존 답변을 참고하여 유사한 답변 링크를 추천해드리고 있습니다. 현재 베타 기능으로 답변이 만족스럽지 않을 수 있는 점 양해 부탁드립니다. 🙏 추가적으로 궁금한 점이 있으시면, 이어서 질문해 주세요. 곧 지식공유자께서 답변해 주실 것입니다.

mhlee님의 프로필 이미지

작성한 질문수

질문하기