当前位置: 首页 > 知识库问答 >
问题:

更改软件包名称Flutter后,应用程序在手机认证时崩溃

欧阳勇
2023-03-14

我想更改项目的包名,所以我更改了build.gradleAndroid.xml中的applicationid。我使用下面的指南https://medium.com/@skyblazar.cc/how-to-change-the-package-name-of-your-flutter-app-4529e6e6e6fc更改了包名

Firebase数据库与我的项目链接,所以我想我也必须更改Firebase中的包名。因此,我在Firebase中添加了新的应用程序,更新了项目的包名,并根据需要添加了SHA密钥。做完所有这些之后,我开始测试我的应用程序。除了电话认证,一切都很好。谷歌认证运行良好。

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)

在下面的代码片段等待FirebaseAuth.instance.verifyPhoneNumber从未运行。verificationcompletesmscodesent从未执行。我在想为什么?在更改包名之前,它工作得很好

  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;
}

共有1个答案

钮边浩
2023-03-14

我通过简单地将flower line添加到app/build.gradle依赖项中来解决这个问题。

implementation "androidx.browser:browser:1.2.0"
 类似资料: