flutterfire icon indicating copy to clipboard operation
flutterfire copied to clipboard

[firebase_auth]: Android physical device not receiving sms

Open engrpatel21 opened this issue 1 year ago • 24 comments

Is there an existing issue for this?

  • [X] I have searched the existing issues.

Which plugins are affected?

Auth

Which platforms are affected?

Android

Description

The verifyPhoneNumber api is not sending otp codes when using debug phone numbers that are in the fire console. It just hangs and about 10mins later it lets me to the next screen to input the verification code. The same thing when testing real numbers. And this is only happening on android, ios is working perfectly.

I have been using been using firebsae_auth for a little over a year now. I have set up my release, debug, and google signed keys into the firebase console.

i have upgraded to the new sms multi factor authentication (only because sms messages stopped sending to android)

I also have set up debug keys in the firebase console for my apps.

Reproducing the issue

// initial setup

final app = await Firebase.initializeApp( options: DefaultFirebaseOptions.currentPlatform); FirebaseAuth.instanceFor(app: app);

await FirebaseAppCheck.instance.activate(

androidProvider: AndroidProvider.debug,

appleProvider: AppleProvider.debug,

);

then when using the verifyPhone api try to send an otp to a debug number or real number i am testing on a real device

Firebase Core version

2.27.0

Flutter Version

3.19.4

Relevant Log Output

//this is the output from start to finish after trying to send an otp code

E/zzb     (16322): Failed to initialize reCAPTCHA config: No Recaptcha Enterprise siteKey configured for tenant/project *
W/System  (16322): Ignoring header X-Firebase-Locale because its value was null.
D/TrafficStats(16322): tagSocket(195) with statsTag=0xffffffff, statsUid=-1
D/TrafficStats(16322): tagSocket(166) with statsTag=0xffffffff, statsUid=-1
D/TrafficStats(16322): tagSocket(118) with statsTag=0xffffffff, statsUid=-1
D/TrafficStats(16322): tagSocket(196) with statsTag=0xffffffff, statsUid=-1
D/TrafficStats(16322): tagSocket(195) with statsTag=0xffffffff, statsUid=-1
I/PlayCore(16322): UID: [10649]  PID: [16322] IntegrityService : requestIntegrityToken(IntegrityTokenRequest{nonce=C_-YGH46p_J4QyWGlTO_MrQjHhiSSGwn7LqWiNGAkV8, cloudProjectNumber=551503664846, network=null})
I/PlayCore(16322): UID: [10649]  PID: [16322] IntegrityService : Initiate binding to the service.
I/PlayCore(16322): UID: [10649]  PID: [16322] IntegrityService : ServiceConnectionImpl.onServiceConnected(ComponentInfo{com.android.vending/com.google.android.finsky.integrityservice.IntegrityService})
I/PlayCore(16322): UID: [10649]  PID: [16322] IntegrityService : linkToDeath
I/PlayCore(16322): UID: [10649]  PID: [16322] OnRequestIntegrityTokenCallback : onRequestIntegrityToken
I/PlayCore(16322): UID: [10649]  PID: [16322] IntegrityService : Unbind from service.
W/System  (16322): Ignoring header X-Firebase-Locale because its value was null.

Flutter dependencies

Expand Flutter dependencies snippet

  app_settings: ^5.1.1
  cached_network_image: ^3.3.1
  collection: ^1.18.0
  dio: ^5.4.2+1
  event_bus: ^2.0.0
  firebase_analytics: ^10.9.0
  firebase_auth: ^4.18.0
  firebase_core: ^2.27.2
  firebase_crashlytics: ^3.4.20
  firebase_messaging: ^14.7.21
  flex_color_scheme: ^7.3.1
  flutter:
    sdk: flutter
  flutter_cache_manager: ^3.3.1
  flutter_datetime_picker_bdaya: ^3.0.2
  flutter_debouncer: ^2.0.0
  flutter_hooks: ^0.20.5
  flutter_keyboard_visibility: ^6.0.0
  flutter_local_notifications: ^17.0.0
  flutter_rating_bar: ^4.0.1
  flutter_riverpod: ^2.5.1
  flutter_svg: ^2.0.10+1
  flutter_timezone: ^1.0.8
  font_awesome_flutter: ^10.7.0
  geolocator: ^12.0.0
  get_storage: ^2.1.1
  go_router: ^14.0.1
  google_fonts: ^6.2.1
  hooks_riverpod: ^2.5.1
  image_cropper: ^6.0.0
  image_picker: ^1.0.7
  intl: ^0.19.0
  jose: ^0.3.4
  json_annotation: ^4.9.0
  profanity_filter: ^2.0.0
  riverpod_annotation: ^2.3.5
  scrollable_positioned_list: ^0.3.8
  share_plus: ^9.0.0
  sizer: ^2.0.15
  skeletonizer: ^1.1.1
  timezone: ^0.9.2
  upgrader: ^10.3.0
  url_launcher: ^6.2.5

Additional context and comments

I have searched through similar issues and all of them were that i need to upload my keys, which are already there. I can see in the firebase console that requests from my android are getting through, but just seems the recaptcha doesnt want to open on the phone.

engrpatel21 avatar May 23 '24 15:05 engrpatel21

do you need any more info on this? our users are blocked from signing up in production.

engrpatel21 avatar May 24 '24 12:05 engrpatel21

@engrpatel21 Thank you for creating this issue, Can you please try to create a new project with just this functionality and see if the issue also exists?

TarekkMA avatar May 24 '24 12:05 TarekkMA

Did you also try different devices, and did you find this issue occurring on all of them?

TarekkMA avatar May 24 '24 12:05 TarekkMA

Did you also try different devices, and did you find this issue occurring on all of them?

yes i have tried on other devices for android, pixel6, s9, s20. i always get the failed to initialize recaptcha. some times the sms takes up to 20 mins to get sent waiting for the api to return a valid response.

@engrpatel21 Thank you for creating this issue, Can you please try to create a new project with just this functionality and see if the issue also exists?

i will try to get this done asap let you know results, its pretty involved with all the setups to get everything going and test on a brand new project.

engrpatel21 avatar May 24 '24 12:05 engrpatel21

According to the 2nd comment in this stack overflow link https://stackoverflow.com/questions/74739659/firebase-sms-authentication-is-delayed-or-sometimes-not-received. It could possibly be an issue with the mobile service provider. It might be worth exploring this possibility. Could you let us know where you are testing (i.e., which country)? Additionally, it might be beneficial to get in touch with Firebase support to inquire about the coverage in your area.

TarekkMA avatar May 24 '24 13:05 TarekkMA

According to the 2nd comment in this stack overflow link https://stackoverflow.com/questions/74739659/firebase-sms-authentication-is-delayed-or-sometimes-not-received. It could possibly be an issue with the mobile service provider. It might be worth exploring this possibility. Could you let us know where you are testing (i.e., which country)? Additionally, it might be beneficial to get in touch with Firebase support to inquire about the coverage in your area.

im in the usa, ive has this system in production for a year without any issues. its also a factor of the api call return time. there is a huge latency to when i get a response back. but when i look at fire base console under app check and authentication, i can see requests that just came in.

engrpatel21 avatar May 24 '24 14:05 engrpatel21

i am currently working trying to repoduce the problem in a seperate project. i will let you know the outcome and relevant details

engrpatel21 avatar May 26 '24 22:05 engrpatel21

ok so i have made a new project. this is the nature. the signing keys and debug keys are the same as our app. all i did was make a new project because the error im getting is the recaptcha error. and this project reproduces that error.

the way you will know its working is when you send the code and the submit button goes from disabled to enabled because of the loading state

now i have enabled app check with authentication, with keys placed in the firebase console, and being able to monitor the requests in the authentication widget within the appcheck section of firebase.

this is the code


import 'package:firebase_auth/firebase_auth.dart';
import 'package:firebase_core/firebase_core.dart';
import 'package:flutter/material.dart';
import 'package:smstest/firebase_options.dart';

void main() async {
  WidgetsFlutterBinding.ensureInitialized();

  final app = await Firebase.initializeApp(
      options: DefaultFirebaseOptions.currentPlatform);
  FirebaseAuth.instanceFor(app: app);
  runApp(const MyApp());
}

class MyApp extends StatelessWidget {
  const MyApp({super.key});

  // This widget is the root of your application.
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Flutter Demo',
      theme: ThemeData(


        colorScheme: ColorScheme.fromSeed(seedColor: Colors.deepPurple),
        useMaterial3: true,
      ),
      home: const MyHomePage(title: 'Flutter Demo Home Page'),
    );
  }
}

class MyHomePage extends StatefulWidget {
  const MyHomePage({super.key, required this.title});



  final String title;

  @override
  State<MyHomePage> createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> {
  int _counter = 0;
  bool isLoading = false;

  void _incrementCounter() {
    setState(() {

      _counter++;
    });
  }

  final phoneNumber = TextEditingController();

  void submitPhoneNumber() async {
    setState(() {
      isLoading = true;
    });
    await FirebaseAuth.instance.verifyPhoneNumber(
      phoneNumber: '+1${phoneNumber.text}',
      timeout: const Duration(seconds: 20),
      verificationCompleted: (PhoneAuthCredential credential) {},
      verificationFailed: (FirebaseAuthException e) {
        print(e.code);
        print(e.message);
        print(e.credential);
        if (e.code == 'invalid-phone-number') {}
      },
      codeSent: (String verificationId, int? resendToken) {
        setState(() {
          isLoading = false;
        });
      },
      codeAutoRetrievalTimeout: (String verificationId) {},
    );
  }

  @override
  Widget build(BuildContext context) {

    return Scaffold(
      appBar: AppBar(

        backgroundColor: Theme.of(context).colorScheme.inversePrimary,

        title: Text(widget.title),
      ),
      body: Center(

        child: Column(
          mainAxisAlignment: MainAxisAlignment.center,
          children: <Widget>[
            const Text(
              'You have pushed the button this many times:',
            ),
            TextField(
              controller: phoneNumber,
            ),
            FilledButton(
                onPressed: isLoading ? null : submitPhoneNumber, child: const Text('Submit')),
          ],
        ),
      ),
      floatingActionButton: FloatingActionButton(
        onPressed: _incrementCounter,
        tooltip: 'Increment',
        child: const Icon(Icons.add),
      ), 
    );
  }
}


this is my app/build.gradle

again this is the error message

E/zzb (31079): Failed to initialize reCAPTCHA config: No Recaptcha Enterprise siteKey configured for tenant/project * I/PlayCore(31079): UID: [10658] PID: [31079] IntegrityService : requestIntegrityToken(IntegrityTokenRequest{nonce=C_-YGH46p_J4QyWGlTO_MrQjHhiSSGwn7LqWiNGAkV8, cloudProjectNumber=551503664846, network=null}) I/PlayCore(31079): UID: [10658] PID: [31079] IntegrityService : Initiate binding to the service. I/PlayCore(31079): UID: [10658] PID: [31079] IntegrityService : ServiceConnectionImpl.onServiceConnected(ComponentInfo{com.android.vending/com.google.android.finsky.integrityservice.IntegrityService}) I/PlayCore(31079): UID: [10658] PID: [31079] IntegrityService : linkToDeath I/PlayCore(31079): UID: [10658] PID: [31079] OnRequestIntegrityTokenCallback : onRequestIntegrityToken I/PlayCore(31079): UID: [10658] PID: [31079] IntegrityService : Unbind from service. W/System (31079): Ignoring header X-Firebase-Locale because its value was null. 4 D/TrafficStats(31079): tagSocket(131) with statsTag=0xffffffff, statsUid=-1 E/FirebaseAuth(31079): [SmsRetrieverHelper] SMS verification code request failed: unknown status code: 17499 Firebase App Check token is invalid.


plugins {
    id "com.android.application"
    id "kotlin-android"
    id "dev.flutter.flutter-gradle-plugin"
    id "com.google.gms.google-services"
}

def localProperties = new Properties()
def localPropertiesFile = rootProject.file('local.properties')
if (localPropertiesFile.exists()) {
    localPropertiesFile.withReader('UTF-8') { reader ->
        localProperties.load(reader)
    }
}

def flutterVersionCode = localProperties.getProperty('flutter.versionCode')
if (flutterVersionCode == null) {
    flutterVersionCode = '1'
}

def flutterVersionName = localProperties.getProperty('flutter.versionName')
if (flutterVersionName == null) {
    flutterVersionName = '1.0'
}

def keystoreProperties = new Properties()
def keystorePropertiesFile = rootProject.file('key.properties')
// def googleApiProperties = new Properties()
// def googleApiPropertiesFile = rootProject.file('google.api.properties')

if (keystorePropertiesFile.exists()) {
    keystoreProperties.load(new FileInputStream(keystorePropertiesFile))

}

android {
    namespace "io.zyka"
    // compileSdk flutter.compileSdkVersion
    compileSdk 34
    // ndkVersion flutter.ndkVersion
     ndkVersion "25.1.8937393"

    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
        coreLibraryDesugaringEnabled true

    }

    kotlinOptions {
        jvmTarget = '1.8'
    }

    sourceSets {
        main.java.srcDirs += 'src/main/kotlin'
    }

    defaultConfig {
        // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
        applicationId "io.zyka"
        // You can update the following values to match your application needs.
        // For more information, see: https://docs.flutter.dev/deployment/android#reviewing-the-gradle-build-configuration.
        minSdkVersion 21
        targetSdkVersion 34
        
        // targetSdkVersion flutter.targetSdkVersion
        versionCode flutterVersionCode.toInteger()
        versionName flutterVersionName
        multiDexEnabled true
    }
    signingConfigs {
       release {
           keyAlias keystoreProperties['keyAlias']
           keyPassword keystoreProperties['keyPassword']
           storeFile keystoreProperties['storeFile'] ? file(keystoreProperties['storeFile']) : null
           storePassword keystoreProperties['storePassword']
       }
   }

    buildTypes {
         debug {
            minifyEnabled true
            signingConfig signingConfigs.release
        }
         release {
            signingConfig signingConfigs.release
            minifyEnabled true
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
            ndk {
              debugSymbolLevel 'FULL'
            }
       }
    }
}

flutter {
    source '../..'
}

dependencies {
    implementation platform('com.google.firebase:firebase-bom:32.6.0')
    implementation 'com.google.firebase:firebase-analytics'
    implementation("com.google.firebase:firebase-auth:22.3.1") 
    // implementation 'androidx.appcompat:appcompat:1.3.1' 
    implementation "androidx.window:window:1.0.0"

    // For Java-friendly APIs to register and unregister callbacks
    implementation "androidx.window:window-java:1.0.0"

    coreLibraryDesugaring 'com.android.tools:desugar_jdk_libs:2.0.3'
}


this is my root/gradle

allprojects {
    repositories {
        google()
        mavenCentral()
    }
}

rootProject.buildDir = '../build'
subprojects {
    project.buildDir = "${rootProject.buildDir}/${project.name}"
}
subprojects {
    project.evaluationDependsOn(':app')
}

tasks.register("clean", Delete) {
    delete rootProject.buildDir
}

this is my gradle properties


distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.4-all.zip

this is the error message which is the same one i have been getting

I/zzb     (31079): ForceRecaptchaV2Flow from phoneAuthOptions = false, ForceRecaptchav2Flow from firebaseSettings = false
W/System  (31079): Ignoring header X-Firebase-Locale because its value was null.
5
D/TrafficStats(31079): tagSocket(6) with statsTag=0xffffffff, statsUid=-1
E/zzb     (31079): Failed to initialize reCAPTCHA config: No Recaptcha Enterprise siteKey configured for tenant/project *
W/System  (31079): Ignoring header X-Firebase-Locale because its value was null.
D/TrafficStats(31079): tagSocket(176) with statsTag=0xffffffff, statsUid=-1

this is my pubspec

name: smstest
description: "A new Flutter project."

publish_to: 'none' 


version: 1.0.0+1

environment:
  sdk: '>=3.3.2 <4.0.0'


dependencies:
  flutter:
    sdk: flutter

.
  cupertino_icons: ^1.0.6
  firebase_auth: ^4.19.6
  firebase_core: ^2.27.2


dev_dependencies:
  flutter_test:
    sdk: flutter


  flutter_lints: ^3.0.0

flutter:


  uses-material-design: true

engrpatel21 avatar May 27 '24 00:05 engrpatel21

I 've noticed that you are using mismatched versions of firebase auth and firebase core, you can use flutterfire install latest to install latest versions.

Can you please try that and see if also the same issue still present ?

TarekkMA avatar May 28 '24 12:05 TarekkMA

there wasn't a command called flutterfire install latest, but there was a command called flutterfire update but it ended up updating to the versions i already have shown you.

name: smstest
description: "A new Flutter project."

publish_to: "none"

version: 1.0.0+1

environment:
  sdk: ">=3.3.2 <4.0.0"

dependencies:
  flutter:
    sdk: flutter

  cupertino_icons: ^1.0.6
  firebase_auth: ^4.19.6
  firebase_core: ^2.27.2

dev_dependencies:
  flutter_test:
    sdk: flutter

  flutter_lints: ^3.0.0

flutter:
  uses-material-design: true

this is the output in the console.

➜  smstest flutterfire install latest
Unhandled exception:
Could not find a command named "install".

Usage: flutterfire <command> [arguments]

Global options:
-h, --help       Print this usage information.
    --verbose    Enable verbose logging.
-v, --version    Print the current CLI version.

Available commands:
  configure   Configure Firebase for your Flutter app. This
              command will fetch Firebase configuration for you
              and generate a Dart file with prefilled
              FirebaseOptions you can use.
  update      Update the version of firebase plugins in your
              pubspec to the latest version and clean your
              workspace to ensure that everything works
              properly.

Run "flutterfire help <command>" for more information about a
command.
#0      CommandRunner.usageException (package:args/command_runner.dart:105:7)
#1      CommandRunner.runCommand (package:args/command_runner.dart:178:13)
#2      CommandRunner.run.<anonymous closure> (package:args/command_runner.dart:122:25)
#3      new Future.sync (dart:async/future.dart:305:31)
#4      CommandRunner.run (package:args/command_runner.dart:122:14)
#5      main (file:///Users/zyka/.pub-cache/hosted/pub.dev/flutterfire_cli-0.2.7/bin/flutterfire.dart:57:48)
<asynchronous suspension>
➜  smstest flutterfire update
Cleaning up current workspace ...
Upgrading all firebase plugins to the latest version ...
Running 'flutter pub get'...
Ready to use the latest version of FlutterFire! 🚀

im also wondering if my versions are write on the android side

dependencies {
    implementation platform('com.google.firebase:firebase-bom:32.6.0')
    implementation 'com.google.firebase:firebase-analytics'
    implementation("com.google.firebase:firebase-auth:22.3.1") 
    // implementation 'androidx.appcompat:appcompat:1.3.1' 
    implementation "androidx.window:window:1.0.0"

    // For Java-friendly APIs to register and unregister callbacks
    implementation "androidx.window:window-java:1.0.0"

    coreLibraryDesugaring 'com.android.tools:desugar_jdk_libs:2.0.3'
}

engrpatel21 avatar May 28 '24 14:05 engrpatel21

an update, i have manually updated firebase_core and firebase_auth manually, then i went in and updated the firebase bom in app/build.gradle along with adding app check and debug tokens on the app check console in firebase. here is the latest code

import 'package:firebase_app_check/firebase_app_check.dart';
import 'package:firebase_auth/firebase_auth.dart';
import 'package:firebase_core/firebase_core.dart';
import 'package:flutter/material.dart';
import 'package:smstest/firebase_options.dart';

void main() async {
  WidgetsFlutterBinding.ensureInitialized();

  final app = await Firebase.initializeApp(
      options: DefaultFirebaseOptions.currentPlatform);
  FirebaseAuth.instanceFor(app: app);
  await FirebaseAppCheck.instance.activate(
    androidProvider: AndroidProvider.debug,
    appleProvider: AppleProvider.debug,
  );
  runApp(const MyApp());
}

class MyApp extends StatelessWidget {
  const MyApp({super.key});

  // This widget is the root of your application.
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Flutter Demo',
      theme: ThemeData(
        colorScheme: ColorScheme.fromSeed(seedColor: Colors.deepPurple),
        useMaterial3: true,
      ),
      home: const MyHomePage(title: 'Flutter Demo Home Page'),
    );
  }
}

class MyHomePage extends StatefulWidget {
  const MyHomePage({super.key, required this.title});

  final String title;

  @override
  State<MyHomePage> createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> {
  int _counter = 0;
  bool isLoading = false;

  void _incrementCounter() {
    setState(() {
      _counter++;
    });
  }

  final phoneNumber = TextEditingController();

  void submitPhoneNumber() async {
    setState(() {
      isLoading = true;
    });
    await FirebaseAuth.instance.verifyPhoneNumber(
      phoneNumber: '+1${phoneNumber.text}',
      timeout: const Duration(seconds: 20),
      verificationCompleted: (PhoneAuthCredential credential) {},
      verificationFailed: (FirebaseAuthException e) {
        print(e.code);
        print(e.message);
        print(e.credential);
        if (e.code == 'invalid-phone-number') {}
      },
      codeSent: (String verificationId, int? resendToken) {
        setState(() {
          isLoading = false;
        });
      },
      codeAutoRetrievalTimeout: (String verificationId) {},
    );
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        backgroundColor: Theme.of(context).colorScheme.inversePrimary,
        title: Text(widget.title),
      ),
      body: Center(
        child: Column(
          mainAxisAlignment: MainAxisAlignment.center,
          children: <Widget>[
            const Text(
              'You have pushed the button this many times:',
            ),
            TextField(
              controller: phoneNumber,
            ),
            FilledButton(
                onPressed: isLoading ? null : submitPhoneNumber,
                child: const Text('Submit')),
          ],
        ),
      ),
      floatingActionButton: FloatingActionButton(
        onPressed: _incrementCounter,
        tooltip: 'Increment',
        child: const Icon(Icons.add),
      ),
    );
  }
}
name: smstest
description: "A new Flutter project."

publish_to: "none"

version: 1.0.0+1

environment:
  sdk: ">=3.3.2 <4.0.0"

dependencies:
  flutter:
    sdk: flutter

  cupertino_icons: ^1.0.6
  firebase_auth: ^4.20.0
  firebase_core: ^2.32.0
  firebase_app_check: ^0.2.2+7

dev_dependencies:
  flutter_test:
    sdk: flutter

  flutter_lints: ^4.0.0

flutter:
  uses-material-design: true
plugins {
    id "com.android.application"
    id "kotlin-android"
    id "dev.flutter.flutter-gradle-plugin"
    id "com.google.gms.google-services"
}

def localProperties = new Properties()
def localPropertiesFile = rootProject.file('local.properties')
if (localPropertiesFile.exists()) {
    localPropertiesFile.withReader('UTF-8') { reader ->
        localProperties.load(reader)
    }
}

def flutterVersionCode = localProperties.getProperty('flutter.versionCode')
if (flutterVersionCode == null) {
    flutterVersionCode = '1'
}

def flutterVersionName = localProperties.getProperty('flutter.versionName')
if (flutterVersionName == null) {
    flutterVersionName = '1.0'
}

def keystoreProperties = new Properties()
def keystorePropertiesFile = rootProject.file('key.properties')
// def googleApiProperties = new Properties()
// def googleApiPropertiesFile = rootProject.file('google.api.properties')

if (keystorePropertiesFile.exists()) {
    keystoreProperties.load(new FileInputStream(keystorePropertiesFile))

}

android {
    namespace "io.zyka"
    // compileSdk flutter.compileSdkVersion
    compileSdk 34
    // ndkVersion flutter.ndkVersion
     ndkVersion "25.1.8937393"

    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
        coreLibraryDesugaringEnabled true

    }

    kotlinOptions {
        jvmTarget = '1.8'
    }

    sourceSets {
        main.java.srcDirs += 'src/main/kotlin'
    }

    defaultConfig {
        // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
        applicationId "io.zyka"
        // You can update the following values to match your application needs.
        // For more information, see: https://docs.flutter.dev/deployment/android#reviewing-the-gradle-build-configuration.
        minSdkVersion 23
        targetSdkVersion 34
        
        // targetSdkVersion flutter.targetSdkVersion
        versionCode flutterVersionCode.toInteger()
        versionName flutterVersionName
        multiDexEnabled true
    }
    signingConfigs {
       release {
           keyAlias keystoreProperties['keyAlias']
           keyPassword keystoreProperties['keyPassword']
           storeFile keystoreProperties['storeFile'] ? file(keystoreProperties['storeFile']) : null
           storePassword keystoreProperties['storePassword']
       }
   }

    buildTypes {
         debug {
            minifyEnabled true
            signingConfig signingConfigs.release
        }
         release {
            signingConfig signingConfigs.release
            minifyEnabled true
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
            ndk {
              debugSymbolLevel 'FULL'
            }
       }
    }
}

flutter {
    source '../..'
}

dependencies {
    implementation platform('com.google.firebase:firebase-bom:33.0.0')
    implementation 'com.google.firebase:firebase-analytics'
    implementation("com.google.firebase:firebase-auth") 
    implementation("com.google.firebase:firebase-appcheck")
    implementation("com.google.firebase:firebase-appcheck-playintegrity")
    // implementation 'androidx.appcompat:appcompat:1.3.1' 
    implementation "androidx.window:window:1.0.0"

    // For Java-friendly APIs to register and unregister callbacks
    implementation "androidx.window:window-java:1.0.0"

    coreLibraryDesugaring 'com.android.tools:desugar_jdk_libs:2.0.3'
}

here is the log output

I/zza     (22069): ForceRecaptchaFlow from phoneAuthOptions = false, ForceRecaptchaFlow from firebaseSettings = false
W/System  (22069): Ignoring header X-Firebase-Locale because its value was null.
D/TrafficStats(22069): tagSocket(91) with statsTag=0xffffffff, statsUid=-1
4
D/TrafficStats(22069): tagSocket(6) with statsTag=0xffffffff, statsUid=-1
I/PlayCore(22069): UID: [10660]  PID: [22069] IntegrityService : requestIntegrityToken(IntegrityTokenRequest{nonce=C_-YGH46p_J4QyWGlTO_MrQjHhiSSGwn7LqWiNGAkV8, cloudProjectNumber=551503664846, network=null})
I/PlayCore(22069): UID: [10660]  PID: [22069] IntegrityService : Initiate binding to the service.
I/PlayCore(22069): UID: [10660]  PID: [22069] IntegrityService : ServiceConnectionImpl.onServiceConnected(ComponentInfo{com.android.vending/com.google.android.finsky.integrityservice.IntegrityService})
I/PlayCore(22069): UID: [10660]  PID: [22069] IntegrityService : linkToDeath
I/PlayCore(22069): UID: [10660]  PID: [22069] OnRequestIntegrityTokenCallback : onRequestIntegrityToken
I/PlayCore(22069): UID: [10660]  PID: [22069] IntegrityService : Unbind from service.
W/io.zyka (22069): Accessing hidden field Ljava/util/Collections$SynchronizedCollection;->mutex:Ljava/lang/Object; (max-target-o, reflection, denied)
W/io.zyka (22069): Accessing hidden field Ljava/util/Collections$SynchronizedCollection;->c:Ljava/util/Collection; (unsupported, reflection, allowed)
W/io.zyka (22069): Accessing hidden method Ljava/util/Collections$SynchronizedSet;-><init>(Ljava/util/Set;Ljava/lang/Object;)V (max-target-o, reflection, denied)
W/io.zyka (22069): Accessing hidden method Ljava/util/Collections$SynchronizedCollection;-><init>(Ljava/util/Collection;Ljava/lang/Object;)V (max-target-o, reflection, denied)
W/System  (22069): Ignoring header X-Firebase-Locale because its value was null.
W/FirebaseAuth(22069): [SmsRetrieverHelper] Timed out waiting for SMS.

if i wait long enough, i can see the request come in to app check panel as an authenticated request image

i also put flutter on the newest version along with the newest versions of these libraries

engrpatel21 avatar May 28 '24 15:05 engrpatel21

also, on apps that have app check enabled with play integrity, isn't recaptcha not supposed to show?

engrpatel21 avatar May 28 '24 16:05 engrpatel21

hi, any updates on this?

engrpatel21 avatar May 30 '24 11:05 engrpatel21

do you need any more info from me?

engrpatel21 avatar Jun 02 '24 14:06 engrpatel21

so am i just going to be ignored?

engrpatel21 avatar Jun 04 '24 16:06 engrpatel21

any update for this issue?

batoul-alani avatar Jun 11 '24 15:06 batoul-alani

Meet the same issue sometimes, any updates on this?

laskdkmg avatar Sep 15 '24 14:09 laskdkmg

Having the same issue, but in my case, users in USA are receiving the messages normally, but on other countries, the sms is delaying hours, or even not arriving at all. Most of the issues are happening with Brazilian and Colombian phones.

jfbaraky avatar Nov 28 '24 12:11 jfbaraky

Any update on this thread ?

webskyneofficiall avatar Jan 13 '25 11:01 webskyneofficiall

i have faced same issue of not sending sms

Aklile-Yilma avatar Feb 24 '25 19:02 Aklile-Yilma

I had the same problem and I was able to solve it. Here was my error log

E/FirebaseAuth(24586): [SmsRetrieverHelper] SMS verification code request failed: unknown status code: 17499 Firebase App Check token is invalid.
D/FirebaseAuth(24586): Invoking original failure callbacks after phone verification failure for +xxxxxxxxxx, error - An internal error has occurred. [ Firebase App Check token is invalid. ]
I/flutter (24586): [firebase_auth/unknown] An internal error has occurred. [ Firebase App Check token is invalid. ]

I fixed it by doing the following:

I install the firebase_app_check library and configured it in main.dart like this

await Firebase.initializeApp();

if (!kDebugMode) {
  await FirebaseAppCheck.instance.activate(
    androidProvider: AndroidProvider.playIntegrity,
    appleProvider: AppleProvider.appAttest,
    webProvider: ReCaptchaV3Provider('recaptcha-v3-site-key'),
  );
} else {
  await FirebaseAppCheck.instance.activate(
    androidProvider: AndroidProvider.debug,
    appleProvider: AppleProvider.debug,
  );
}

This configuration prints a debug token. You can check it here: https://firebase.google.com/docs/app-check/flutter/debug-provider?hl=en

To make it work in debug mode, I registered this token in Firebase Console → App Check → Apps. After doing this, everything worked as expected in debug.

When I submitted the app to Google Play (internal testing), it worked as well.

So, in summary:

  • In production, everything works as expected.
  • In debug mode, you must manually register the printed debug token for each device in Firebase Console.

Hope this helps!

danilomayhua avatar Mar 08 '25 01:03 danilomayhua

@danilomayhua steel same issue even with manually register and i wonder my app distributed internally not via play store i will not able to send otp ?? I used it in 2022 and it works well without any complications.

beloufaimededdine avatar Mar 19 '25 18:03 beloufaimededdine

@danilomayhua I tested the exact same configuration. when you say

This configuration prints a debug token. You can check it here: https://firebase.google.com/docs/app-check/flutter/debug-provider?hl=en It works for me on ios platform. But it does not output any debug token in android. ! with firebase_app_check: ^0.3.2+5 firebase_core: ^3.13.0 firebase_auth: ^5.5.2

sacketty avatar Apr 11 '25 08:04 sacketty

@beloufaimededdine I'm not sure if it will work if it's not distributed via Play Store.

@sacketty I've implemented several configurations before, so you might be missing some of them. This comment contains the configurations I implemented: https://github.com/firebase/flutterfire/issues/11565#issuecomment-1715642047

danilomayhua avatar Apr 11 '25 23:04 danilomayhua