0

I am crating a custom code generator with the source_gen package. I want to add break points in the generator class and debug my code when I running dart run build_runner build command.

Is there any way for debugging custom build runner generators in dart and android studio?

NOTE: There is two similar questions (this and this) that answers is about to use build.dart file from .dart_tool/build/entrypoint but the build.dart script not running anything in new flutter versions (flutter 3.35.4 and dart 3.9.2)

1 Answer 1

1

Right, the old way doesn't work since 2.9.0.

In 2.10.0 you can pass flags to dart run build_runner build to enable debugging with observatory

dart run build_runner build --dart-jit-vm-arg=--observe --dart-jit-vm-arg=--pause-isolates-on-start

And then, you can attach android studio debugger to the dart vm. use this document and create a Run/Debug Configuration using Dart Remote Debug option. (the document is for phpStorm but it also works in android studio and other jetbrains IDEs.)

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks for your answer, it works in build_runner ^2.10.0, but it seems there is no way to debug older versions of build_runner, anyway, I accepted your answer and added some explanations for use in Android Studio.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.