更改程序包名称后,应用程序在电话验证后崩溃-Flutter [英] App crashes upon phone authentication after changing package name - Flutter

查看:70
本文介绍了更改程序包名称后,应用程序在电话验证后崩溃-Flutter的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想更改项目的程序包名称,因此在 build.gradle android.xml 中更改了 applicationId .我使用以下指南更改了软件包名称 https://medium.com/@skyblazar.cc/如何更改包装名称-您的Flutter-app-4529e6e6e6fc

I wanted to change the package name of my project so I changed the applicationId in build.gradle and in android.xml. I changed package name using below guide https://medium.com/@skyblazar.cc/how-to-change-the-package-name-of-your-flutter-app-4529e6e6e6fc

Firebase数据库已与我的项目链接,所以我认为我也必须更改Firebase中的程序包名称.因此,我在Firebase中添加了带有项目的更新包名称的新应用,并根据需要添加了SHA键.完成所有这些操作后,我开始测试我的应用程序.除电话身份验证外,其他所有功能均正常运行.Google身份验证工作正常.

Firebase database was linked with my project so I thought I had to change the package name in Firebase too. So, I added new app in Firebase with UPDATED package name of the project and added SHA key as required. After doing all this I started to test my app. Everything is working fine except phone authentication. Google authentication is working fine.

我不知道为什么,在进行电话身份验证时,出现错误并导致应用崩溃.内置函数 FirebaseAuth.instance.verifyPhoneNumber 从未执行.我想知道为什么吗?

I don't know why, while phone authentication, I get below error and app get crashed. Build in function FirebaseAuth.instance.verifyPhoneNumber never executed. I'm wondering why?

应用终止前出错

I/flutter (15570): New user result at the end before await: null
E/zzf     (15570): Problem retrieving SafetyNet Token: 7:
W/ActivityThread(15570): handleWindowVisibility: no activity for token android.os.BinderProxy@7518a38
D/ViewRootImpl@9a0d0b4[MainActivity](15570): MSG_WINDOW_FOCUS_CHANGED 0 1
D/InputMethodManager(15570): prepareNavigationBarInfo() DecorView@b62e3fa[MainActivity]
D/InputMethodManager(15570): getNavigationBarColor() -855310
I/DecorView(15570): createDecorCaptionView >> DecorView@1ec25a[], isFloating: false, isApplication: true, hasWindowDecorCaption: false, hasWindowControllerCallback: true
W/System  (15570): Ignoring header X-Firebase-Locale because its value was null.
I/System.out(15570): (HTTPLog)-Static: isSBSettingEnabled false
I/System.out(15570): (HTTPLog)-Static: isSBSettingEnabled false
D/InputTransport(15570): Input channel constructed: fd=97
D/ViewRootImpl@141d474[RecaptchaActivity](15570): setView = DecorView@1ec25a[RecaptchaActivity] TM=true MM=false
D/ViewRootImpl@141d474[RecaptchaActivity](15570): dispatchAttachedToWindow
D/ViewRootImpl@141d474[RecaptchaActivity](15570): Relayout returned: old=[0,0][1080,2220] new=[0,0][1080,2220] result=0x7 surface={valid=true 545211748352} changed=true
D/OpenGLRenderer(15570): eglCreateWindowSurface = 0x7efbe16f80, 0x7ef1271010
D/ViewRootImpl@141d474[RecaptchaActivity](15570): MSG_RESIZED: frame=Rect(0, 0 - 1080, 2220) ci=Rect(0, 63 - 0, 0) vi=Rect(0, 63 - 0, 0) or=1
D/InputTransport(15570): Input channel destroyed: fd=132
D/AndroidRuntime(15570): Shutting down VM
E/AndroidRuntime(15570): FATAL EXCEPTION: main
E/AndroidRuntime(15570): Process: com.xxxxx.xxxxx, PID: 15570
E/AndroidRuntime(15570): java.lang.NoClassDefFoundError: Failed resolution of: Landroidx/browser/customtabs/CustomTabsIntent$Builder;
E/AndroidRuntime(15570):    at com.google.firebase.auth.internal.RecaptchaActivity.zza(com.google.firebase:firebase-auth@@20.0.1:13)
E/AndroidRuntime(15570):    at com.google.android.gms.internal.firebase-auth-api.zzth.zzb(com.google.firebase:firebase-auth@@20.0.1:7)
E/AndroidRuntime(15570):    at com.google.android.gms.internal.firebase-auth-api.zzth.onPostExecute(Unknown Source:2)
E/AndroidRuntime(15570):    at android.os.AsyncTask.finish(AsyncTask.java:695)
E/AndroidRuntime(15570):    at android.os.AsyncTask.access$600(AsyncTask.java:180)
E/AndroidRuntime(15570):    at android.os.AsyncTask$InternalHandler.handleMessage(AsyncTask.java:712)
E/AndroidRuntime(15570):    at android.os.Handler.dispatchMessage(Handler.java:106)
E/AndroidRuntime(15570):    at android.os.Looper.loop(Looper.java:214)
E/AndroidRuntime(15570):    at android.app.ActivityThread.main(ActivityThread.java:7073)
E/AndroidRuntime(15570):    at java.lang.reflect.Method.invoke(Native Method)
E/AndroidRuntime(15570):    at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:494)
E/AndroidRuntime(15570):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:965)
E/AndroidRuntime(15570): Caused by: java.lang.ClassNotFoundException: Didn't find class "androidx.browser.customtabs.CustomTabsIntent$Builder" on path: DexPathList[[zip file "/data/app/com.storeifie.storeify-DOxHXgyJA9JAe6BK8YeeWA==/base.apk"],nativeLibraryDirectories=[/data/app/com.storeifie.storeify-DOxHXgyJA9JAe6BK8YeeWA==/lib/arm64, /data/app/com.storeifie.storeify-DOxHXgyJA9JAe6BK8YeeWA==/base.apk!/lib/arm64-v8a, /system/lib64, /system/vendor/lib64]]
E/AndroidRuntime(15570):    at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:134)
E/AndroidRuntime(15570):    at java.lang.ClassLoader.loadClass(ClassLoader.java:379)
E/AndroidRuntime(15570):    at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
E/AndroidRuntime(15570):    ... 12 more
I/Process (15570): Sending signal. PID: 15570 SIG: 9
Lost connection to device.
Exited (sigterm)

下面是 verifyPhone 函数的代码段.

在以下代码段中,等待FirebaseAuth.instance.verifyPhoneNumber 从未运行. verificationComplete smsCodeSent 从未执行过.我想知道为什么吗?更改软件包名称之前一切正常

In below code snippet await FirebaseAuth.instance.verifyPhoneNumber never ran. verificationComplete and smsCodeSent never got executed. I'm wondering why? It was working fine before changing package name

  Future<dynamic> verifyPhone(phoneNo, BuildContext context) async {
    var completer = Completer<dynamic>();
    dynamic newUserResult;

    Future<String> getOTPresult() async {
      print("Dialog shown");
      await showModalBottomSheet(
        context: context,
        backgroundColor: Colors.transparent,
        builder: (context) => Container(
          height: 270,
          child: OTPBottomSheet(controller: _otpController),
        ),
      );
      return _otpController.text;
    }
 
    //  >>>>>>>>>>>>> On Complete

    final PhoneVerificationCompleted verificationComplete =
        (AuthCredential authCred) async {
      print(" I N S I D E   C O M P L E T E ");
      newUserResult = await signInWithPhoneNumber(authCred);
      completer.complete(newUserResult);
    };
 
    //  >>>>>>>>>>>>> On Timeout

    final PhoneCodeAutoRetrievalTimeout autoRetrieve = (String verID) {
      print("\n2. Auto retrieval time out");
      completer.complete(newUserResult);
    };

    // >>>>>>>>>>>>>  On manual code verification

    final PhoneCodeSent smsCodeSent =
        (String verID, [int forceCodeResend]) async {
      print(" I N S I D E   C O D E   S E N T");
      var OTPDialogResult = await getOTPresult();
       if (OTPDialogResult != null) {
        AuthCredential authCred = PhoneAuthProvider.credential(
            verificationId: verID, smsCode: OTPDialogResult);
         newUserResult = AuthService().signInWithPhoneNumber(authCred);
        if (!completer.isCompleted) {
          completer.complete(newUserResult);
        }
      }
    };

      //  >>>>>>>>>>>>> On Ver failed
    
      final PhoneVerificationFailed verificationFailed =
        (Exception authException) {
       completer.complete(newUserResult);
    };

    await FirebaseAuth.instance
        .verifyPhoneNumber(
          phoneNumber: phoneNo,
          timeout: Duration(seconds: 50),
          verificationCompleted: verificationComplete,
          verificationFailed: verificationFailed,
          codeSent: smsCodeSent,
          codeAutoRetrievalTimeout: autoRetrieve,
        ).catchError((error) {
      print(error.toString());
    });

    print("New user result at the end before await: " + newUserResult.toString());
    newUserResult = await completer.future;
    print("New user result at the end after await: " + newUserResult.toString());
    return newUserResult;
  }

signInWithPhoneNumber 函数


  Future signInWithPhoneNumber(AuthCredential authCreds) async {
    try {
      UserCredential result = await FirebaseAuth.instance.signInWithCredential(authCreds);
      User customUser = result.user;
    return _userFormFirebaseUser(customUser).getuid;
  }

  CustData _userFormFirebaseUser(User user) {
    print("----> Inside _userFormFirebaseUser and user ID: " + user.uid);
    return user != null
        ? CustData(
            custId: user.uid,
          )
        : null;
  }


// --- CustData  model class 

class CustData {
  String custId;
  String custName;
  String custPhNo;
  String custContactNO;
  DateTime custDateOfBirth;
  Map<String, dynamic> address;
  String cartID;
  CustData({
    this.custId,
    this.custName,
    this.custPhNo,
    this.custDateOfBirth,
    this.address,
    this.cartID,
    this.custContactNO,
  });

  CustData.initial() : custId = '';
  String get getuid => this.custId;
}

推荐答案

我通过简单地将以下行添加到app/build.gradle依赖项中来解决了这个问题.

I solved the problem by simply adding below line into app/build.gradle dependencies.

implementation "androidx.browser:browser:1.2.0"

这篇关于更改程序包名称后,应用程序在电话验证后崩溃-Flutter的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆