Skip to content

🐛 Flutter Build APK: Unhandled Exception: [core/not-initialized] Firebase has not been correctly initialized #7145

@mhmzdev

Description

@mhmzdev

I have been facing this problem only in Release Mode in Debug mode its working fine.

I'm using firebase_core and firebase_storage plugins only

⚠ Exception

enter image description here

🩺 Flutter Doctor

enter image description here

Followed all the steps of integrating Firebase in Flutter:

Step 1:

Added in main.dart before runApp()

  • WidgetsFlutterBinding.ensureInitialized();
  • await Firebase.initializeApp();
void main() async {
  WidgetsFlutterBinding.ensureInitialized();
  await Firebase.initializeApp();
  runApp(MyApp());
}

Step 2:

Added in build.gradle root folder

  • classpath 'com.google.gms:google-services:4.2.0'
buildscript {
    ext.kotlin_version = '1.3.50'
    repositories {
        google()
        jcenter()
    }

    dependencies {
        classpath 'com.android.tools.build:gradle:4.1.0'
        classpath 'com.google.gms:google-services:4.2.0' <-- // here it is
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
    }
}

Step 3:

Added in build.gradle app level

  • apply plugin: 'com.google.gms.google-services'
apply plugin: 'com.android.application'
apply plugin: 'com.google.gms.google-services' <--- // here it is
apply plugin: 'kotlin-android'
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"

Step 4:

  • Updated the firebase_core
  • Updated the firebase_storage

Step 5:

Added the google-service.json to app level

enter image description here

Step 5:

  • flutter clean
  • Re-downloaded the google-services.json

I have already gone through the solutions available on Stack Overflow. Hence, whatever link you are going to shared, I might have gone through it already.

Please let me know if you need anything else :)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions