Various PlatformExceptions recorded with single_factor_auth_flutter version SDK 7.0.1 (latest version)

Framework: Flutter
SDK: single_factor_auth_flutter version 7.0.1 (latest version)
Network: sapphire_mainnet

We are having a number of issues with single_factor_auth_flutter SDK version 7.0.1 (latest version) on our live app. Previously I had reported the PlatformException- lateinit property singleFactorAuth has not been initialized issue but this problem is still happening after updating the proguard-rules.pro file with. Here is the complete content of the proguard-rules.pro file

-keepclassmembers class com.web3auth.single_factor_auth_flutter.* {
    <fields>;
    <init>();
    <methods>;
}
-keep class com.web3auth.singlefactorauth.** { *; }
-keep class com.web3auth.singlefactorauth.types.** { *; }
-keep class com.web3auth.singlefactorauth.** { *; }
-keep class com.web3auth.singlefactorauth.types.** { *; }

# Keep Gson serialized classes (prevents issues with reflection-based deserialization)
-keep class com.google.gson.** { *; }
-keepattributes *Annotation*

-keep class org.torusresearch.fetchnodedetails.types.** { *; }
-keepclassmembers enum * { *; }

# Keep the j2objc annotations that Guava needs
-dontwarn com.google.j2objc.annotations.RetainedWith

The PlatformException(error, null, null, null) issue is followed by the PlatformException(error, lateinit property singleFactorAuth has not been initialized, null issue and we have noticed that the issues resolve when the user clears the app data and app cache after they encountered the issue initially but this is breaking the user experience. Would love to know why this is happening and how to resolve this totally so it does not happen in the first place

Also another issue we encounter frequently on our live app is PlatformException(error, public nonce is missing, public nonce is missing, null) Our crashlytics service has been recording this more frequently and this is usually happening for our new users. We do not understand what may be leading to this issue and would love to know how to move forward with potential fixes for the issue

Thanks — I hear you and I appreciate the detailed info. I’ve pulled the key facts and written up likely causes + next steps so the support team can triage quickly.

Summary of what you reported

  • SDK: MetaMask Embedded Wallets (Web3Auth) — single_factor_auth_flutter
  • SDK version: 7.0.1 (latest)
  • Platform / Framework: Flutter (Android release builds impacted)
  • Network: sapphire_mainnet
  • Errors seen (Crashlytics / screenshot):
    • PlatformException(error, null, null, null)
    • PlatformException(error, lateinit property singleFactorAuth has not been initialized, …)
    • PlatformException(error, public nonce is missing, public nonce is missing, …)
  • You’ve already added a proguard-rules.pro (content included in your message) and clearing app data/cache temporarily resolves the issue for affected users.

What I still need (only if you don’t already have it handy)
Please share these only if you can — they’re most useful for reproducing/fixing the bug and won’t be requested otherwise:

  • The Flutter code snippet that initializes the single_factor_auth_flutter SDK and the login snippet (where you call into the SDK). If you have a custom Application class or native Android init, include that.
  • Android release Gradle settings relevant to R8/ProGuard (minifyEnabled, shrinkResources, proguardFiles entries used for release). A quick paste of the buildTypes { release { … } } block is enough.
  • A full Crashlytics stacktrace / relevant logcat lines for the two exceptions (especially the public nonce error). The screenshot helps but the textual stacktrace is more actionable.
  • Whether the problem reproduces on a debug build (minify disabled) or only on proguard/minified release builds.
  • Devices / Android OS versions where you see the issue most commonly (if known).

Immediate hypotheses and recommended checks (so you can try quick fixes)

  1. Race / initialization ordering (likely cause of lateinit singleFactorAuth error)
  • Symptom:

Note: This response was generated by an AI bot and may require further verification. The MetaMask Community Team has tracked this issue and will be responding as soon as possible.

Additionally, we would recommend you to join our biweekly Office Hours to get this resolved even faster. MetaMask Developer Office Hours

final web3AuthOptions = Web3AuthOptions(
  network: Web3AuthNetwork.sapphire_mainnet,
  clientId: ...,
  sessionTime: 2592000,
);

await _singleFactorAuthentication.init(
  web3AuthOptions,
);

Causes both the PlatformException(error, null, null, null) and the PlatformException(error, lateinit property singleFactorAuth has not been initialized, null issue on our live app

buildTypes {
    debug {
        ...
    }
    profile {
        ...
    }
    release {
        shrinkResources true
        minifyEnabled true
        signingConfig signingConfigs.release
        proguardFiles(
                getDefaultProguardFile("proguard-android-optimize.txt"),
                "proguard-rules.pro"
        )
    }
}

For the PlatformException(error, public nonce is missing, public nonce is missing, …) issue:

String: PlatformException(error, public nonce is missing, public nonce is missing, null)
#0      SingleFactorAuthFlutter._handlePlatformException (package:single_factor_auth_flutter/single_factor_auth_flutter.dart:139)
#1      SingleFactorAuthFlutter.connect (package:single_factor_auth_flutter/single_factor_auth_flutter.dart:42)
  File "<asynchronous suspension>"
#3      AuthRepositoryImplementation.authenticateUserWithSFAUsing.<fn> (package:sky_trade/features/auth/data/repositories/auth_repository_implementation.dart:592)
  File "<asynchronous suspension>"
#5      DataHandler.handleData (package:sky_trade/core/utils/clients/data_handler.dart:17)
  File "<asynchronous suspension>"
#7      AuthBloc._authenticateUserWithSFA (package:sky_trade/features/auth/presentation/blocs/auth_bloc/auth_bloc.dart:510)
  File "<asynchronous suspension>"
#9      Bloc.on.<fn>.handleEvent (package:bloc/src/bloc.dart:226)

For the PlatformException(error, lateinit property singleFactorAuth has not been initialized, …) issue:

String: PlatformException(error, D1.t: lateinit property singleFactorAuth has not been initialized, D1.t: lateinit property singleFactorAuth has not been initialized, null)
#0      SingleFactorAuthFlutter._handlePlatformException (package:single_factor_auth_flutter/single_factor_auth_flutter.dart:139)
#1      SingleFactorAuthFlutter.initialize (package:single_factor_auth_flutter/single_factor_auth_flutter.dart:28)
  File "<asynchronous suspension>"
#3      DataHandler.handleData (package:sky_trade/core/utils/clients/data_handler.dart:17)
  File "<asynchronous suspension>"
#5      SFAConfigurationBloc._configure (package:sky_trade/features/auth/presentation/blocs/s_f_a_configuration_bloc/s_f_a_configuration_bloc.dart:40)
  File "<asynchronous suspension>"
#7      Bloc.on.<fn>.handleEvent (package:bloc/src/bloc.dart:226)

For the PlatformException(error, null, null, null) issue:

String: PlatformException(error, null, null, null)
#0      StandardMethodCodec.decodeEnvelope (package:flutter/src/services/message_codecs.dart:653)
#1      MethodChannel._invokeMethod (package:flutter/src/services/platform_channel.dart:367)
  File "<asynchronous suspension>"
#3      SingleFactorAuthFlutter.init (package:single_factor_auth_flutter/single_factor_auth_flutter.dart:21)
  File "<asynchronous suspension>"
#5      AuthRepositoryImplementation.configureSFA.<fn> (package:sky_trade/features/auth/data/repositories/auth_repository_implementation.dart:504)
  File "<asynchronous suspension>"
#7      DataHandler.handleData (package:sky_trade/core/utils/clients/data_handler.dart:17)
  File "<asynchronous suspension>"
#9      Future.wait.<fn> (dart:async/future.dart:525)
  File "<asynchronous suspension>"
#11      SessionBloc._compute (package:sky_trade/features/auth/presentation/blocs/session_bloc/session_bloc.dart:130)
  File "<asynchronous suspension>"
#13      Bloc.on.<fn>.handleEvent (package:bloc/src/bloc.dart:226)

The problem is only happening on release build whether minification/proguard is enabled or not

So far we have observed that the PlatformException(error, null, null, null) and the PlatformException(error, lateinit property singleFactorAuth has not been initialized, …) problem is happening across all our Android users. The issue is not happening at all on iOS