.yaml file bellow:

    sdk: flutter
  cupertino_icons: ^0.1.2
  fluttertoast: ^2.0.9
  dio: ^1.0.6
  json_serializable: ^2.0.0
  build_runner: ^1.0.0
  json_annotation: ^2.0.0

when I run:

Launching lib/main.dart on Android SDK built for x86 in debug mode...
Initializing gradle...
Resolving dependencies...
Gradle task 'assembleDebug'...
Built build/app/outputs/apk/debug/app-debug.apk.
D/OpenGLRenderer( 5350): HWUI GL Pipeline
I/OpenGLRenderer( 5350): Initialized EGL, version 1.4
D/OpenGLRenderer( 5350): Swap behavior 1
D/        ( 5350): HostConnection::get() New Host Connection established 
0xa12b3ec0, tid 5379
D/EGL_emulation( 5350): eglCreateContext: 0xa127cf60: maj 2 min 0 rcv 2
D/        ( 5350): SurfaceInterface::setAsyncMode: set async mode 1
D/EGL_emulation( 5350): eglMakeCurrent: 0xa127cf60: ver 2 0 (tinfo         
E/flutter ( 5350): [ERROR:flutter/shell/common/shell.cc(188)] Dart Error: 
error: import of dart:mirrors with --enable-mirrors=false
E/flutter ( 5350): [ERROR:flutter/shell/common/engine.cc(176)] Could not 
prepare to run the isolate.
E/flutter ( 5350): [ERROR:flutter/shell/common/engine.cc(123)] Engine not prepare and launch isolate.
E/flutter ( 5350): 
[ERROR:flutter/shell/platform/android/android_shell_holder.cc(167)] Could not launch engine in configuration.

i know the problem is that 'json_serializable' but i didn't know how to resolve it. or is there any way to transform between model and json

Solution 1: MarkusH

I did stumble across your post on my own search after solutions with your problem.

I assume that you want to use json_serializable for your own sourceCode creation. If this is the case you should have json_serializable: ^2.0.0 under the dev_dependencies.


json_serializable does use dartlang/source_gen internally. source_gen in turn does reference dart:mirrors, which is not supported in flutter (as told in this post).

So long story in short: - through removing the dependency on json_serializable from your "build" dependencies you remove the dependency on mirrors which is stopping your flutterBuild.

i know the problem is that 'json_serializable' but i didn't know how to resolve it. or is there any way to transform between model and json

I did not really got that part. At least for me this is not enough information to provide help on your modelgeneration.

Could try if you post a class in which you use json_serializable and the generated partial class.

Solution 2: user3234870

I had similar problem. I was using appengine plugin with MethodChannel and once I removed appengine dependency it all worked fine.