-1

Frnds... I'm facing a severe issue in release mode after I build an app... It crashes after launching the app... I got the following error in the console as "Tried to send viewport metrics from Android to Flutter but this FlutterView was not attached to a FlutterEngine." Anybody could give solve it would be help

In debug mode... It is working just fine....

While in release mode it forces the app to close while launching.

Sometimes I will not getting any errors... But the app still crashes. While I made it run in debug flutterengine renders its view after release mode this engine does not render it.

Marcin Orlowski
  • 72,056
  • 11
  • 123
  • 141
Gokulb1998
  • 21
  • 2

1 Answers1

0

Try adding this to your main function -

WidgetsFlutterBinding.ensureInitialized();

So finally your main function should like this -

void main() {
   WidgetsFlutterBinding.ensureInitialized();
   runApp(MyApp());
}
Shubham Jain
  • 51
  • 1
  • 3
  • I disabled the R8 option in the app/build.Gradle file..because it is shrinking my code while I build the app. so I run my command as flutter build apk --no-shrink..Then it works well without app crashes. – Gokulb1998 Mar 04 '20 at 06:59