Search code examples
androidflutterfirebasedartsplash-screen

Splash screen stuck and never shows the main.dart Flutter


After running my app, it's showing the splash screen and never goes away. Even if I close & reboot the app and even I run the flutter run by Flutter run lib/main.dart is showing nothing only but the splash screen , I also added the WidgetsFlutterBinding.ensureInitialized(); but still nothing is working for me. trying everything like flutter clean & flutter pub get I haven't use any package for the splash-screen. plz can anyone identify the problem would appriciated. I've added my terminal below after launching the app.

Thanks again.

W/FlutterActivityAndFragmentDelegate(18992): A splash screen was provided to Flutter, but this is deprecated. See flutter.dev/go/android-splash-migration for migration steps.
E/flutter (18992): [ERROR:flutter/runtime/dart_vm_initializer.cc(41)] Unhandled Exception: PlatformException(null-error, Host platform returned null value for non-null return value., null, null)
E/flutter (18992): #0      FirebaseCoreHostApi.optionsFromResource (package:firebase_core_platform_interface/src/pigeon/messages.pigeon.dart:246:7)
E/flutter (18992): <asynchronous suspension>
E/flutter (18992): #1      MethodChannelFirebase.initializeApp (package:firebase_core_platform_interface/src/method_channel/method_channel_firebase.dart:89:25)
E/flutter (18992): <asynchronous suspension>
E/flutter (18992): #2      Firebase.initializeApp (package:firebase_core/src/firebase.dart:43:31)
E/flutter (18992): <asynchronous suspension>
E/flutter (18992): #3      main (package:pdfscanner/main.dart:7:3)
E/flutter (18992): <asynchronous suspension>
E/flutter (18992): 

my main.dart looks like this:

Future<void> main() async {
  WidgetsFlutterBinding.ensureInitialized();
  await Firebase.initializeApp();
  runApp(
    MaterialApp(
      debugShowCheckedModeBanner: false,
      title: "Document Scanner",
      home: HomePage(),
    ),
  );
}

this is my build.gradle in android mainstream

   buildscript {
    ext.kotlin_version = '1.6.10'
    repositories {
        google()
        mavenCentral()
    }

    dependencies {
        classpath 'com.android.tools.build:gradle:7.1.2'
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
        classpath 'com.google.gms:google-services:4.3.15'
    }
}

allprojects {
    repositories {
        google()
        mavenCentral()
    }
}

rootProject.buildDir = '../build'
subprojects {
    project.buildDir = "${rootProject.buildDir}/${project.name}"
}
subprojects {
    project.evaluationDependsOn(':app')
}

task clean(type: Delete) {
    delete rootProject.buildDir
}

Solution

  • adding this on the app level build.gradle will definitely solve the problem.

    dependencies {
        classpath 'com.android.tools.build:gradle:7.3.0'
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
        classpath "com.google.gms:google-services:4.3.15"   // this makes all the difference
    }