Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PlatformException error in dart_vm_initializer.cc

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

I got this error while running my app at the line await Firebase.initializeApp();

E/flutter ( 9119): [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 ( 9119): #0      FirebaseCoreHostApi.optionsFromResource (package:firebase_core_platform_interface/src/pigeon/messages.pigeon.dart:242:7)
E/flutter ( 9119): <asynchronous suspension>
E/flutter ( 9119): #1      MethodChannelFirebase.initializeApp (package:firebase_core_platform_interface/src/method_channel/method_channel_firebase.dart:89:25)
E/flutter ( 9119): <asynchronous suspension>
E/flutter ( 9119): #2      Firebase.initializeApp (package:firebase_core/src/firebase.dart:40:31)
E/flutter ( 9119): <asynchronous suspension>
E/flutter ( 9119): #3      main (package:travysavvy/main.dart:14:3)
E/flutter ( 9119): <asynchronous suspension>
E/flutter ( 9119): 

Please note that I am using firebase core version as below

 firebase_core: ^1.20.0

Right now, I'm trying to run this on an android emulator. I have added google-services.json to <app_name>/android/app, the following to <app_name>/android/build.gradle

dependencies {
    ...
    classpath 'com.google.gms:google-services:4.3.13'
    ...
}

and this to <app_name>/android/app

dependencies {
    ...
    implementation platform('com.google.firebase:firebase-bom:30.3.1')
    implementation 'com.google.firebase:firebase-analytics'
    ...
}

Any would be appreciated. Thanks.

like image 838
Athul Sukumaran Avatar asked Dec 21 '25 16:12

Athul Sukumaran


1 Answers

could you please show android/app/build.gradle ?
and try adding apply plugin: 'com.google.gms.google-services'
then it looks something like this:

apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"

to this:

apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"
apply plugin: 'com.google.gms.google-services'
like image 73
idk Avatar answered Dec 23 '25 10:12

idk