flutter_ali_auth icon indicating copy to clipboard operation
flutter_ali_auth copied to clipboard

APP一开始运行没有开流量的情况后,再开启流量无法调用起页面,报错

Open DaYang816 opened this issue 8 months ago • 0 comments

Version

0.7.0

Platforms

Android

Device Model

Xiao Mi mix3 (Android 10)

flutter info

Flutter assets will be downloaded from https://storage.flutter-io.cn. Make sure you trust this source!
[√] Flutter (Channel stable, 3.13.9, on Microsoft Windows [版本 10.0.19045.3693], locale zh-CN)
    • Flutter version 3.13.9 on channel stable at D:\Protable\flutterSDK\3.13.9
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision d211f42860 (7 weeks ago), 2023-10-25 13:42:25 -0700
    • Engine revision 0545f8705d
    • Dart version 3.1.5
    • DevTools version 2.25.0
    • Pub download mirror https://pub.flutter-io.cn
    • Flutter download mirror https://storage.flutter-io.cn

[√] Windows Version (Installed version of Windows is version 10 or higher)

[√] Android toolchain - develop for Android devices (Android SDK version 33.0.0)
    • Android SDK at D:\Protable\Android\Sdk
    • Platform android-33, build-tools 33.0.0
    • ANDROID_HOME = D:\Protable\Android\Sdk
    • ANDROID_SDK_ROOT = D:\Protable\Android\Sdk
    • Java binary at: D:\Program Files (x86)\Android\Android Studio\jre\bin\java
    • Java version OpenJDK Runtime Environment (build 11.0.12+7-b1504.28-7817840)
    • All Android licenses accepted.

[√] Chrome - develop for the web
    • Chrome at C:\Program Files\Google\Chrome\Application\chrome.exe

[!] Visual Studio - develop Windows apps (Visual Studio Enterprise 2022 17.5.5)
    • Visual Studio at D:\Program Files\Microsoft Visual Studio\2022\Enterprise
    • Visual Studio Enterprise 2022 version 17.5.33627.172
    • Windows 10 SDK version 10.0.17763.0
    X Visual Studio is missing necessary components. Please re-run the Visual Studio installer for the "Desktop development with C++" workload, and include these components:      
        MSVC v142 - VS 2019 C++ x64/x86 build tools
         - If there are multiple build tool versions available, install the latest
        C++ CMake tools for Windows
        Windows 10 SDK

[√] Android Studio (version 2021.2)
    • Android Studio at D:\Program Files (x86)\Android\Android Studio
    • Flutter plugin can be installed from:
       https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
       https://plugins.jetbrains.com/plugin/6351-dart
    • Java version OpenJDK Runtime Environment (build 11.0.12+7-b1504.28-7817840)

[√] Connected device (4 available)
    • MIX 3 (mobile)    • d5e5f0d9 • android-arm64  • Android 10 (API 29)
    • Windows (desktop) • windows  • windows-x64    • Microsoft Windows [版本 10.0.19045.3693]
    • Chrome (web)      • chrome   • web-javascript • Google Chrome 115.0.5790.98
    • Edge (web)        • edge     • web-javascript • Microsoft Edge 120.0.2210.61

[√] Network resources
    • All expected network resources are available.

! Doctor found issues in 1 category.

How to reproduce?

APP一开始运行没有开流量的情况开了WiFi,点击一键登录提示没有开流量,开启流量后报错。 如果APP一开始运行开了流量,无论怎么切换流量按钮,插件正常。 报错位置是下面这个一键登录触发事件,try catch. 好像是参数没有更新导致的

  @override
  void onInit() async {
    prefs = Get.find<SharedPreferences>();
    // language = prefs.getString(StorageConstants.lang);
    // PackageInfo packageInfo = await PackageInfo.fromPlatform();
    // logD(packageInfo.packageName);
    try {
      AliAuthClient.removeHandler();
      AliAuthClient.handleEvent(onEvent: _onEvent);
      bool? initSuccess = await AliAuthClient.initSdk(
        authConfig: authConfig,
      );
      logE("初始化:$initSuccess");
      if (!(initSuccess ?? false)) {
        logE("初始化SDK失败");
      }
    } on PlatformException catch (e) {
      final AuthResultCode resultCode = AuthResultCode.fromCode(
        e.code,
      );
      WsWidget.wsToast(resultCode.message);
      logE("初始化SDK出现错误1:$e");
    }
    super.onInit();
  }
  onClickLogin() async {
    AliAuthClient.quitLoginPage();
    try {
      await AliAuthClient.login(timeout: 5);
    } on PlatformException catch (e) {
      final AuthResultCode resultCode = AuthResultCode.fromCode(
        e.code,
      );
      WsWidget.wsToast(resultCode.message);
      logE("初始化SDK出现错误2:$e");
    }
  }

resultCode.message 为 终端环境检测失败(1.终端不支持认证,2终端检测参数错误,3.初始化未成功)

Logs

I/flutter (12905): │ ⛔ 初始化:true
I/flutter (12905): │ ⛔ 初始化SDK出现错误2:PlatformException(600025, 初始化失败或未初始化, null, null)
D/AuthSDK (12905): CacheMonitor:{"u":{"endTime":"2023年12月11日 16:20:56.471","isSuccess":"true","startTime":"2023年12月11日 16:20:56.470","suspendDisMissVC":false,"wholeMS":"1"},"s":"","c":{"traceId":"0ffab91b-ac83-4ebe-bd60-b334ae155973","appVersion":"1.0.0","um_aaid":"6a8d6a3c9706b69e68d46dcfd9610b03","signature":"5ca1b859cdd317188dc99ea92401c7ce","utdid":"4e3ed2d06ab9ca45b57a3d7040994fc0","archiveName":"logOnlineStandardCuxw","carrierSdkVersion":"","deviceName":"MIX 3","vendorKey":"","osVersion":"10","createTime":1702282856472,"monitorVersion":"2.1","sdkVersion":"2.12.15","packageName":"com.yongjiang.airobot","networkType":null,"deviceBrand":"Xiaomi","uniqueId":"2d6696adb6015e62a39117466e110e57"},"action":"sdk.quit.auth","apiLevel":"1","osType":"Android"}

Example code (optional)

No response

Contact

No response

DaYang816 avatar Dec 11 '23 08:12 DaYang816