Falling back to loading access token from NSUserDefaults because of simulator bug in Flutter

1,301

Since, it was an error which was unknown to most of us, I decided to write it myself since I have found out the solution. Here it goes.

I have tried a lot of things, but with my team I figured something and that was, there was something with the Firebase package version. For what I did was:

  1. Make a new project totally
  2. Connect it to firebase
  3. Use the current version firebase_auth 0.8.3
  4. And run the project, and make sure your login works
  5. When you are done, run the old project and see it will work.

The possibility was the packages usually gets stored in the same file for all the projects, so doing cat .packages will give you the idea.

Thanks, and happy learning!!!

Share:
1,301
Alok
Author by

Alok

A hands-on creative software developer with excellent communication, organizational skills. A hard-working person who believes in completing things, who has an experience in Object-Oriented Programming as well as working on different platforms. Great dedication with excellent focus on doing various task. A learning enthusiast who is comfortable with multiple tech languages & frameworks and would love to work in a very dynamic & aspirational environment.

Updated on December 12, 2022

Comments

  • Alok
    Alok over 1 year

    I have been tired of debugging this problem, but to be very precise, I'm unable to find any perfect solution for this.

    Previously my app used to perform smooth, without any hassle, but now I'm getting this error while logging into my account.

    Possible Problem: It's something with the Firebase issue, but the simulator is not able to store the accessToken in the simulator.

    I have followed these questions :

    1. Falling back to loading/storing access token from NSUserDefaults because of simulator bug
    2. Falling back to loading access token from NSUserDefaults because of simulator bug

    Now my app runs fine, the problem occurs when I'm trying to login. I have seen the solution, but nothing works out for me as per the above researches.

    What I have done so far is:

    1. Restarted the app
    2. Restarted my system, and tried to run the app
    3. Changed the version of the FIREBASE_CORE and FIREBASE_AUTH in my pubspec.yaml file
    4. Re-installed XCode. Same problem
    5. This is flutter firebase packages in my pubspec.yaml file
    • firebase_core: ^0.3.0
    • firebase_auth: ^0.8.0

    With all those, things nothing worked out. The error seems to be consistent.

    Code for LogIn:

    final AuthCredential credential = EmailAuthProvider.getCredential(email: this.email.text, password: this.password.text);
    this._auth.signInWithCredential(credential).then((user) async {
    }, onError: (e){
       Helpers.showError(context, (e as PlatformException).message);
    });
    

    Error:

    1. While running the app for the first time:

    Launching lib/main.dart on iPhone 7 in debug mode...
    Running Xcode build...                                                  
                                                       
     ├─Assembling Flutter resources...                           4.1s
     └─Compiling, linking and signing...                         7.0s
    Xcode build done.                                           14.5s
    Configuring the default Firebase app...
    5.20.0 - [Firebase/Core][I-COR000004] App with name __FIRAPP_DEFAULT does not exist.
    Configured the default Firebase app __FIRAPP_DEFAULT.
    Falling back to loading access token from NSUserDefaults because of simulator bug
    Falling back to storing access token in NSUserDefaults because of simulator bug
    Falling back to loading access token from NSUserDefaults because of simulator bug
    Falling back to storing access token in NSUserDefaults because of simulator bug
    Falling back to loading access token from NSUserDefaults because of simulator bug
    Falling back to storing access token in NSUserDefaults because of simulator bug
    5.20.0 - [Firebase/Analytics][I-ACS023007] Analytics v.50801000 started
    5.20.0 - [Firebase/Analytics][I-ACS023008] To enable debug logging set the following application argument: -FIRAnalyticsDebugEnabled
    flutter: in the main builder
    flutter: in the init page state                                         
    flutter: building the init page                                         
        "LocalUploadTask <A98F1971-4A48-4CDD-8658-567C6E24AE0E>.<1>"        
    ), _NSURLErrorFailingURLSessionTaskErrorKey=LocalUploadTask <A98F1971-4A48-4CDD-8658-567C6E24AE0E>.<1>, NSLocalizedDescription=cancelled} [-999]
    <Google/Utilities/Network/ERROR> Encounter network error. Code, error: -999, Error Domain=NSURLErrorDomain Code=-999 "cancelled" UserInfo={NSErrorFailingURLStringKey=https://play.googleapis.com/log, NSErrorFailingURLKey=https://play.googleapis.com/log, _NSURLErrorRelatedURLSessionTaskErrorKey=(
        "LocalUploadTask <A98F1971-4A48-4CDD-8658-567C6E24AE0E>.<1>"        
    ), _NSURLErrorFailingURLSessionTaskErrorKey=LocalUploadTask <A98F1971-4A48-4CDD-8658-567C6E24AE0E>.<1>, NSLocalizedDescription=cancelled}
    5.20.0 - [GULNetwork][I-NET901017] <Google/Utilities/Network/ERROR> Encounter network error. Code, error: -999, Error Domain=NSURLErrorDomain Code=-999 "cancelled" UserInfo={NSErrorFailingURLStringKey=https://play.googleapis.com/log, NSErrorFailingURLKey=https://play.googleapis.com/log, _NSURLErrorRelatedURLSessionTaskErrorKey=(
        "LocalUploadTask <A98F1971-4A48-4CDD-8658-567C6E24AE0E>.<1>"        
    ), _NSURLErrorFailingURLSessionTaskErrorKey=LocalUploadTask <A98F1971-4A48-4CDD-8658-567C6E24AE0E>.<1>, NSLocalizedDescription=cancelled}
            [C3.1.1 06A394ED-7FAF-45F0-ACCA-755A5E942EB5 ::1.56091<->::1.8080]
            Connected Path: satisfied (Path is satisfied), interface: lo0   
            Duration: 1.659s, DNS @0.005s took 0.013s, TCP @0.038s took 0.001s, TLS took 0.316s
            bytes in/out: 3907/808, packets in/out: 10/9, rtt: 0.000s, retransmitted packets: 0, out-of-order packets: 0
                                                                            
                                                                            
    Your Facebook SDK is out of date. We recommend upgrading to the latest Version 4.37.0, to ensure your app's performance is not affected and to take advantage of our newest features!
                                                                            
    Facebook SDK for iOS: https://developers.facebook.com/docs/ios/         
    Facebook SDK for Android: https://developers.facebook.com/docs/android/ 
            [C2.1.1 D009F134-D0FD-41DF-BCB2-713CBD8875DF ::1.56090<->::1.8080]
            Connected Path: satisfied (Path is satisfied), interface: lo0   
            Duration: 1.729s, DNS @0.005s took 0.023s, TCP @0.037s took 0.014s, TLS took 0.295s
            bytes in/out: 4353/1054, packets in/out: 10/9, rtt: 0.000s, retransmitted packets: 0, out-of-order packets: 0
    5.20.0 - [Firebase/Core][I-COR000020] Error posting to Clearcut: Error Domain=NSURLErrorDomain Code=-999 "cancelled" UserInfo={NSErrorFailingURLStringKey=https://play.googleapis.com/log, NSErrorFailingURLKey=https://play.googleapis.com/log, _NSURLErrorRelatedURLSessionTaskErrorKey=(
        "LocalUploadTask <A98F1971-4A48-4CDD-8658-567C6E24AE0E>.<1>"        
    ), _NSURLErrorFailingURLSessionTaskErrorKey=LocalUploadTask <A98F1971-4A48-4CDD-8658-567C6E24AE0E>.<1>, NSLocalizedDescription=cancelled}, with Status Code: 0
    flutter: building the init page                                         
    flutter: building the init page                                         
            [C4.1.1 09BF4681-8112-4F65-84AA-824DC0C0F7A3 ::1.56101<->::1.8080]
            Connected Path: satisfied (Path is satisfied), interface: lo0   
            Duration: 0.622s, DNS @0.003s took 0.002s, TCP @0.020s took 0.001s, TLS took 0.148s
            bytes in/out: 3761/1543, packets in/out: 9/10, rtt: 0.000s, retransmitted packets: 0, out-of-order packets: 0
    flutter: Calling GET API: /init                                         
    Syncing files to device iPhone 7...                                     
    flutter: {token: null, is_user_active: false, user: null}       
    Syncing files to device iPhone 7...                                                          4,586ms (!)
    

    2. When I try to log in:

    Challenge SecTrustResultType 5 for www.googleapis.com, properties: (
            {
            type = error;
            value = "Root certificate is not trusted.";
        }
    )
    Cancelling authentication challenge for https://www.googleapis.com/identitytoolkit/v3/relyingparty/verifyPassword?key=XXXXXXXXXXXXXXXXXXXXXX
        "LocalDataTask <A48A2557-0E1B-4F61-8E54-B319538559DA>.<1>"
    ), _NSURLErrorFailingURLSessionTaskErrorKey=LocalDataTask <A48A2557-0E1B-4F61-8E54-B319538559DA>.<1>, NSLocalizedDescription=cancelled} [-999]
    

    3. Firebase throws:

    Network error (such as timeout, interrupted connection or unreachable host) has occurred
    

    Flutter Doctor:

    Doctor summary (to see all details, run flutter doctor -v):
    [✓] Flutter (Channel master, v1.7.9-pre.9, on Mac OS X 10.14.5 18F132, locale en-US)
     
    [✓] Android toolchain - develop for Android devices (Android SDK version 28.0.3)
    [✓] Xcode - develop for iOS and macOS (Xcode 10.0)
    [✓] iOS tools - develop for iOS devices
    [✓] Chrome - develop for the web
    [!] Android Studio (version 3.4)
        ✗ Flutter plugin not installed; this adds Flutter specific functionality.
        ✗ Dart plugin not installed; this adds Dart specific functionality.
    [✓] Connected device (3 available)
    
    ! Doctor found issues in 1 category.
    

    What can I try next?