Flutter 应用程序在添加Flatter firebase验证ui后崩溃

Flutter 应用程序在添加Flatter firebase验证ui后崩溃,flutter,firebaseui,flutter-dependencies,Flutter,Firebaseui,Flutter Dependencies,Flatter firebase auth UI出现一些问题,因为firebase_auth版本未匹配问题 我的Flitter应用程序崩溃了,无法识别问题,在android studio中打开后,我得到了问题,它就在这里 Caused by: java.lang.IllegalStateException: Default FirebaseApp is not initialized in this process com.mycom.mypetshop. Make sure to call F

Flatter firebase auth UI出现一些问题,因为firebase_auth版本未匹配问题

我的Flitter应用程序崩溃了,无法识别问题,在android studio中打开后,我得到了问题,它就在这里

Caused by: java.lang.IllegalStateException: Default FirebaseApp is not initialized in this process com.mycom.mypetshop. Make sure to call FirebaseApp.initializeApp(Context) first.
        at com.google.firebase.FirebaseApp.getInstance(com.google.firebase:firebase-common@@16.0.2:240)
        at com.google.firebase.auth.FirebaseAuth.getInstance(Unknown Source)
        at io.flutter.plugins.firebaseauth.FirebaseAuthPlugin.<init>(FirebaseAuthPlugin.java:54)
        at io.flutter.plugins.firebaseauth.FirebaseAuthPlugin.registerWith(FirebaseAuthPlugin.java:47)
        at io.flutter.plugins.GeneratedPluginRegistrant.registerWith(GeneratedPluginRegistrant.java:20)
        at com.vyapari2online.mypetshop.MainActivity.onCreate(MainActivity.java:11)
        at android.app.Activity.performCreate(Activity.java:5990)
原因:java.lang.IllegalStateException:默认FirebaseApp未在此进程com.mycom.mypetshop中初始化。确保首先调用FirebaseApp.initializeApp(上下文)。
位于com.google.firebase.FirebaseApp.getInstance(com.google.firebase:firebase common@@16.0.2:240)
位于com.google.firebase.auth.FirebaseAuth.getInstance(未知源)
在io.flatter.plugins.firebaseauth.FirebaseAuthPlugin.(FirebaseAuthPlugin.java:54)
位于io.flatter.plugins.firebaseauth.FirebaseAuthPlugin.registerWith(FirebaseAuthPlugin.java:47)
在io.flatter.plugins.GeneratedPluginRegistrant.registerWith处(GeneratedPluginRegistrant.java:20)
位于com.vyapari2online.mypetshop.MainActivity.onCreate(MainActivity.java:11)
位于android.app.Activity.performCreate(Activity.java:5990)
如何解决这个问题

在项目“app”中,已解决Google Play services库依赖关系 依赖于另一个精确版本(例如“[15.0.1]”,但不是 正在解析为该版本。库显示的行为将 不知道

依赖失败:com.google.android.gms:play服务标志:15.0.1 ->com.google.android.gms:游戏服务库@[ 15.0.1],但play services的基本版本是16.0.1

以下依赖项是直接或间接的项目依赖项 具有可传递的依赖关系,从而导致与 问题 --项目“app”依赖于项目“firebase\u auth”,该项目依赖于com.google.firebase:firebase-auth@16.0.2 --项目“app”依赖于项目“firebase_core”,该项目依赖于com.google.firebase:firebase-core@16.0.4 --项目“app”依赖于项目“cloud\u firestore”,该项目依赖于com.google.firebase:firebase-firestore@17.1.1 --项目“app”依赖于项目“google\u sign\u in”,该项目依赖于com.google.android.gms:play services-auth@16.0.1

对于扩展调试信息,请使用以下命令行执行Gradle ./gradlew--info:app:assembleDebug查看到的dep-endence路径 工件。此错误消息来自google服务梯度 插件,在https上报告问题:// github.com/google/play-services-plugins并通过添加 将“googleServices{disableVersionCheck=false}”添加到b build.gradle 文件


#flatter_firebase_ui有很多问题#谷歌请雇佣我,我可以帮助你的开发者

你需要在使用前初始化
FirebaseApp
。你可以将它添加到你的
onCreate
方法中

@Override
public void onCreate() {
    super.onCreate();
    FirebaseApp.initializeApp(this);
}
还要确保在
build.gradle中有依赖项

dependencies {
    ....
}

apply plugin: 'com.google.gms.google-services'
依赖项配置 对于gradle问题,请确保您的Android SDK和Firebase/Firestore插件版本兼容。以下是对我有效的方法:

dependencies {
        classpath 'com.android.tools.build:gradle:3.2.1'
        classpath 'com.google.gms:google-services:4.2.0'
        classpath 'com.google.firebase:firebase-auth:16.0.5'
}
在模块/app
build.gradle
中:

android {
    compileSdkVersion 27

    lintOptions {
        disable 'InvalidPackage'
    }

    defaultConfig {
        // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
        applicationId "com.timeswap.timeswapcore"
        minSdkVersion 17
        targetSdkVersion 27
        versionCode flutterVersionCode.toInteger()
        versionName flutterVersionName
        multiDexEnabled true
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }

...
}
具体来说,请注意
编译DKversion
targetSdkVersion
,以及
谷歌服务
firebase_auth
的版本号。摆弄这些数字最终会让我找到这个配置,它可能会帮助您找到合适的配置

Firebase或Firestore初始化 至于应用程序初始化,我有这个

Firestore firestore = Firestore.instance;
firestore.settings(timestampsInSnapshotsEnabled: true);
在我的
\u initFirestore
中,它在
super.initState()之后调用

Firebase(以及我使用过的所有其他Firebase插件)的初始化方式类似,但使用
Firebase\u核心:
依赖项,而不是
pubspec.yaml
中的
cloud\u firestore:

例如,从
flatter/plugins/packages/firebase\u存储
GitHub:

您还可以作为入门指南使用Flatter Firebase Auth UI


作为将来的参考,您可以在Github上导航到
flatter/plugins/packages/{package name}
,并在
examples/lib
中找到
main.dart
进行演示。也可以利用它来解决依赖性问题!

我也面临同样的问题,并通过在AndroidManifest.xml中添加Facebook应用程序id来解决
尝试在Android studio上运行Android应用程序,您将收到错误消息

Midhilaj,下面的内容您做得如何?
@override
void initState() {
    super.initState();
    _initFirestore();
    checkCurrentUser();
}
void main() async {
  final FirebaseApp app = await FirebaseApp.configure(
    name: 'test',
    options: FirebaseOptions(
      googleAppID: Platform.isIOS
          ? '1:159623150305:ios:4a213ef3dbd8997b'
          : '1:159623150305:android:ef48439a0cc0263d',
      gcmSenderID: '159623150305',
      apiKey: 'AIzaSyChk3KEG7QYrs4kQPLP1tjJNxBTbfCAdgg',
      projectID: 'flutter-firebase-plugins',
    ),
  );
  final FirebaseStorage storage = FirebaseStorage(
      app: app, storageBucket: 'gs://flutter-firebase-plugins.appspot.com');
  runApp(MyApp(storage: storage));
}