Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/flutter/9.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
调用Firebase.instance.verifyPhoneNumber()会导致Flatter应用程序(android)崩溃_Firebase_Flutter_Firebase Authentication - Fatal编程技术网

调用Firebase.instance.verifyPhoneNumber()会导致Flatter应用程序(android)崩溃

调用Firebase.instance.verifyPhoneNumber()会导致Flatter应用程序(android)崩溃,firebase,flutter,firebase-authentication,Firebase,Flutter,Firebase Authentication,我正在尝试将电话身份验证添加到我的应用程序中,但它导致我的应用程序崩溃。(我现在只使用android。) 代码如下: import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:groci/Shared/Constants.dart'; class AuthServices { final FirebaseAuth _auth = FirebaseAuth

我正在尝试将电话身份验证添加到我的应用程序中,但它导致我的应用程序崩溃。(我现在只使用android。)

代码如下:

import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:groci/Shared/Constants.dart';

class AuthServices {

  final FirebaseAuth _auth = FirebaseAuth.instance;
  final TextEditingController _verController = TextEditingController();

  Future registerWithPhone(BuildContext context, String phoneNo) async {
    print("it's working till here : $phoneNo");
    try {
      await _auth.verifyPhoneNumber(phoneNumber: phoneNo,
          verificationCompleted: (AuthCredential authCredential) {
            print("Verification Complete");
          },

          verificationFailed: (FirebaseAuthException exception) {
            print(exception.toString());
          },

          codeSent: (String verCode, int rewind) {
            print("Code sent");
            showDialog(context: context, builder: (_) {
              return AlertDialog(
                title: Text("Enter the verification code"),
                actions: <Widget>[
                  TextField(
                    controller: _verController,
                    decoration: formFieldDecoration.copyWith(
                        hintText: "VerCode"),
                  ),
                  FlatButton(
                    child: Text("Enter"),
                    onPressed: () {
                      print("working");
                    },
                  )
                ],
              );
            });
          },

          codeAutoRetrievalTimeout: (String code) {
            print("didn't work");
          });

    }catch (e) {
      print(e.toString());
    }
  }
}

我在网上找不到多少帮助。我在firebase控制台中设置了sha-1密钥,并启用了电话身份验证。

我面临着完全相同的问题

我猜您尚未启用设备检查API。由于某种原因,它因此崩溃了。您只需在云平台上启用设备检查API

我认为在一些更新之后,他们已经做出了这样的改变,即对于安全网,您需要SH1身份验证以及启用设备检查API

您可以按照前面提到的步骤操作


请告诉我您是否需要进一步的措施。

我面临着完全相同的问题

我猜您尚未启用设备检查API。由于某种原因,它因此崩溃了。您只需在云平台上启用设备检查API

我认为在一些更新之后,他们已经做出了这样的改变,即对于安全网,您需要SH1身份验证以及启用设备检查API

您可以按照前面提到的步骤操作


请让我知道您是否需要进一步的步骤。

按照Ayush所说的做了,并实现了androidx。这使得它能够像Ayush所说的那样工作,并实现了androidx。这就成功了
I/flutter (10581): it's working till here.
E/zza     (10581): Problem retrieving SafetyNet Token: 7: 
I/zzip    (10581): Provider GmsCore_OpenSSL not available
D/AndroidRuntime(10581): Shutting down VM
E/AndroidRuntime(10581): FATAL EXCEPTION: main
E/AndroidRuntime(10581): Process: com.example.groci, PID: 10581
E/AndroidRuntime(10581): java.lang.NoClassDefFoundError: Failed resolution of: Landroidx/browser/customtabs/CustomTabsIntent$Builder;
E/AndroidRuntime(10581):    at com.google.firebase.auth.internal.RecaptchaActivity.zza(com.google.firebase:firebase-auth@@20.0.0:92)
E/AndroidRuntime(10581):    at com.google.firebase.auth.api.internal.zzeq.zza(com.google.firebase:firebase-auth@@20.0.0:79)
E/AndroidRuntime(10581):    at com.google.firebase.auth.api.internal.zzeq.onPostExecute(com.google.firebase:firebase-auth@@20.0.0:88)