Google sign in "Choose an account to continue" loop

455

Solution 1

It turned out that for some reason, my package name and application id were different, and so entering the application id instead of the package name when getting my OAuth 2.0 Client ID solved it.

Solution 2

Can you try flutter clean and check if this persist?

Solution 3

It seems that the FitKit class has a requestPermissions method. Use that along with FitKit.hasPermissions to ensure that the necessary permissions are granted.

Share:
455
Tariq_J99
Author by

Tariq_J99

Updated on December 01, 2022

Comments

  • Tariq_J99
    Tariq_J99 over 1 year

    I'm trying to implement the following packages with my Flutter app:

    https://pub.dev/packages/permission_handler

    https://pub.dev/packages/fit_kit

    and I've done so by writing the following two functions:

    Future<void> checkPermissions() async {
     var status = await Permission.activityRecognition.status;
     if (status.isUndetermined || status.isDenied) {
       Permission.activityRecognition.request();
    }  else if (status.isPermanentlyDenied) {
       openAppSettings();
     }
    }
    
    Future<void> read() async {
     results.clear();
     await checkPermissions();
     for (DataType type in [DataType.STEP_COUNT, DataType.DISTANCE]) {
       try {
         results[type] = await FitKit.read(
           type,
           dateFrom: _weekBeginning,
           dateTo: _now,
         );
       } on UnsupportedException catch (e) {
         results[e.dataType] = [];
       }
     }
     dailyStepBuffer = 0;
     dailyDistanceBuffer = 0;
     for(FitData dataPoint in results[DataType.STEP_COUNT]){
       print(dataPoint);
       dailyStepBuffer += dataPoint.value.round();
     }
     for(FitData dataPoint in results[DataType.DISTANCE]){
       print(dataPoint);
       dailyDistanceBuffer += dataPoint.value.round();
     }
     setState(() {
       dailySteps = dailyStepBuffer;
       dailyDistance = dailyDistanceBuffer;
     });
    }
    

    The functions and packages work as intended on iOS, but for some reason, whenever I call read() on an Android device, it shows me this sign in screen, and when I click on my account, it does nothing and I get the error:

    E/flutter ( 8211): [ERROR:flutter/lib/ui/ui_dart_state.cc(166)] Unhandled Exception: PlatformException(FitKit, User denied permission access, null)

    I've gotten the OAuth 2.0 client ID using my SHA-1 fingerprint, added <uses-permission android:name="android.permission.ACTIVITY_RECOGNITION"/> to my AndroidManifest.xml file and added the following to my build.gradle:

    implementation 'com.google.android.gms:play-services-fitness:19.0.0'
    implementation 'com.google.android.gms:play-services-auth:18.1.0'
    

    Unfortunately though, none of these appear to have solved the issue. I'd be extremely grateful if anyone could help me solve this, thanks!

  • Tariq_J99
    Tariq_J99 almost 4 years
    Ran flutter clean and unfortunately the issue persists
  • Tariq_J99
    Tariq_J99 almost 4 years
    I've now implemented requestPermissions and hasPermissions, and unfortunately the issue persists
  • Ahmed Hafiz
    Ahmed Hafiz almost 4 years
    Does the phone you're testing on support google fit? Can you try another device?
  • Tariq_J99
    Tariq_J99 over 3 years
    Apologies for the late reply, but fortunately I managed to solve the issue. Thanks for the assistance though Ahmed, appreciate it!