6
votes

I recently updated the flutter. For running flutter project I am using android via usb. And after updating every project on startup shows black screen. Previous version worked fine. I tried to change launch splash screen(drawable/launch_background.xml) in android to white but black screen shows after splash screen. This is the simple code I am trying to run

void main()=> runApp(MyApp());
class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context){
    return MaterialApp(
        home:MyHomePage(),      
    );
  }
}

So how can I remove black screen on startup?

The black screen like here. As I said black screen shows after updating flutter to a new version. And I downgraded the flutter version to old and black screen disappeared.

4
can you share the codeblock for MyHomePageAbhijith K
@Abhijith I just created a new flutter project in android studio and nothing has been changed.The codeblock is defaultKOrra

4 Answers

10
votes

I had the same problem when I switched to beta channel of flutter.
I noticed there is another launch_background.xml file in drawable-v21 folder.

so I copied the content of launch_background.xml in drawable folder to launch_background.xml in drawable-v21 and it worked.

1
votes

If you see the black window background of the activity showing until Flutter renders its first frame you should add this on your AndroidManifest, between < activity> ... < /activity>

<meta-data
       android:name="io.flutter.embedding.android.SplashScreenDrawable"
   android:resource="@drawable/launch_background"
/>
0
votes

The solution to this problem is quite easy. I have been facing this problem since months and now I came up with a solution.

Run this command in terminal

flutter config --no-enable-android-embedding-v2

And from next project you won't face such problem. But make sure that 'enable-android-embedding-v2' is set to 'false' by running command

flutter config

on terminal.

Thank You!

0
votes

I had the same issue with my flutter project. It has a simple fix in the AndroidManifest.xml. Make sure that

       <meta-data
          android:name="io.flutter.embedding.android.NormalTheme"
          android:resource="@style/NormalTheme"
        />

Is above

       <meta-data
          android:name="io.flutter.embedding.android.SplashScreenDrawable"
          android:resource="@drawable/launch_background"
        />

In the AndroidManifest.xml