简体   繁体   English

在 WidgetsFlutterBinding.ensureInitialized() 中给出异常; 等待 Firebase.initializeApp();

[英]giving exception in WidgetsFlutterBinding.ensureInitialized(); await Firebase.initializeApp();

I have used我用过

 WidgetsFlutterBinding.ensureInitialized();
  await Firebase.initializeApp();

in main function it is giving exception while debugging and emulator displays blank screen when it is runned without debugging在主要功能中,它在调试时给出异常,并且模拟器在没有调试的情况下运行时显示空白屏幕

It is showing following exception -> Exception has occurred.它显示以下异常 -> 发生异常。 PlatformException (PlatformException(channel-error, Unable to establish connection on channel., null, null)) PlatformException (PlatformException(channel-error, Unable to establish connection on channel., null, null))

I have updated dependencies, also added firebase core and also updated it please help me in this problem我已经更新了依赖项,还添加了 firebase 核心并更新了它,请帮助我解决这个问题

IMAGE OF MY CODE WHERE IT IS SHOWING ERROR我的代码显示错误的图像

output of pub outdated酒吧的输出过时了

[*] indicates versions that are not the latest available.

Package Name              Current   Upgradable  Resolvable  Latest   

direct dependencies: all up-to-date.

dev_dependencies: all up-to-date.

transitive dependencies:
string_scanner            *1.1.0    *1.1.0      *1.1.0      1.2.0
term_glyph                *1.2.0    *1.2.0      *1.2.0      1.2.1
test_api                  *0.4.9    *0.4.9      *0.4.9      0.4.17
vector_math               *2.1.2    *2.1.2      *2.1.2      2.1.4
all dependencies are up-to-date.```

Check your Firebase SDK dependencies in Project build.gradle file and Application build.gradle file在项目 build.gradle 文件和应用程序 build.gradle 文件中检查您的 Firebase SDK 依赖项

buildscript {
  repositories {
    // Check that you have the following line (if not, add it):
    google()  // Google's Maven repository
  }
  dependencies {
    ...
    // Add this line
    classpath 'com.google.gms:google-services:4.3.13'
  }
}

allprojects {
  ...
  repositories {
    // Check that you have the following line (if not, add it):
    google()  // Google's Maven repository
    ...
  }
}

And in your app level build.grandle:在您的应用级 build.grandle 中:

apply plugin: 'com.android.application'
// Add this line
apply plugin: 'com.google.gms.google-services'

dependencies {
  // Import the Firebase BoM
  implementation platform('com.google.firebase:firebase-bom:30.2.0')

  // Add the dependency for the Firebase SDK for Google Analytics
  // When using the BoM, don't specify versions in Firebase dependencies
  implementation 'com.google.firebase:firebase-analytics'

  // Add the dependencies for any other desired Firebase products
  // https://firebase.google.com/docs/android/setup#available-libraries
}

Did you also run flutter clean and flutter pub get again?您是否也再次运行flutter cleanflutter pub get

Otherwise can you run flutter pub outdated ans share the output?否则你能运行flutter pub outdated ans share 输出吗?

1.Add to pubspec.yaml 1.添加到pubspec.yaml

firebase_core :

2.Add to main.dart 2.添加到main.dart

import 'package:firebase_core/firebase_core.dart';

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

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Firebase 构建消费者异常<usermanager> // [core/no-app] 没有创建 Firebase App '[DEFAULT]' - 调用 Firebase.initializeApp()</usermanager> - Firebase Exception building a Consumer<UserManager> // [core/no-app] No Firebase App '[DEFAULT]' has been created - call Firebase.initializeApp() 没有创建 Firebase App - 调用 Firebase.initializeApp() - No Firebase App has been created - call Firebase.initializeApp() Firebase.initializeApp名称参数在移动端需要,web不需要 - Firebase.initializeApp name parameter is needed in mobile but not in web 没有创建 Firebase App '[DEFAULT]' - 在 Flutter 和 Firebase 调用 Firebase.initializeApp() - No Firebase App '[DEFAULT]' has been created - call Firebase.initializeApp() in Flutter and Firebase React Native 错误:没有创建 Firebase App '[DEFAULT]' - 调用 firebase.initializeApp() - React Native Error: No Firebase App '[DEFAULT]' has been created - call firebase.initializeApp() 没有 Firebase 应用程序“[DEFAULT]”已创建 - 在 Flutter 中调用 Firebase.initializeApp() - No Firebase App '[DEFAULT]' has been created - call Firebase.initializeApp() in Flutter Firebase.initializeApp(); 和 FirebaseMessaging.instance.getToken() 抛出 android 本机异常 - Firebase.initializeApp(); and FirebaseMessaging.instance.getToken() throws android native exceptions 异步/等待 firebase 存储 - async/await with firebase storage Flutter Web - No Firebase App '[DEFAULT]' has been created - call Firebase App.initializeApp() (app/no-app) - Flutter Web - No Firebase App '[DEFAULT]' has been created - call Firebase App.initializeApp() (app/no-app) FirebaseError: Firebase: 否 Firebase App '[DEFAULT]' 已创建 - 调用 Firebase App.initializeApp() {颤动网络} - FirebaseError: Firebase: No Firebase App '[DEFAULT]' has been created - call Firebase App.initializeApp() (app/no-app). {Flutter web}
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM