Closed guvanch07 closed 9 months ago
i fixed it by setting timeout: 0
https://stackoverflow.com/questions/65803670/error-receiving-broadcast-intent-when-using-smsretriever
and don't set timeout
@guvanch07 Where in the code are you setting / not setting the timeout ? Can you provide a reproducible code sample ?
By not setting the timeout, are you referring to codeAutoRetrievalTimeout
?
Also, can you provide the entire crash log ?
@darshankawar no, i am not referring to codeAutoRetrievalTimeout
Future<void> _otpToPhoneAuth({
required String phoneNumber,
required String localeCode,
int? forceResendingToken,
bool isResend = false,
}) async {
await _auth.verifyPhoneNumber(
phoneNumber: phoneNumber,
verificationCompleted: (PhoneAuthCredential credential) async {
await _auth.signInWithCredential(credential);
},
verificationFailed: (FirebaseAuthException e) {
Sentry.captureMessage(
'Phone verification error: ${e.code} ${e.message ?? ''}');
log(e.code, name: 'sendSms');
_errorHandlerVerify(e.message ?? '', e.code);
},
codeAutoRetrievalTimeout: (String verificationId) {},
forceResendingToken: forceResendingToken,
timeout: const Duration(seconds: 0), // i mean this timeout
codeSent: (String verificationId, int? resendToken) async {.....},
);
}
@darshankawar crash log
D/AndroidRuntime(12745): Shutting down VM
I/QarthLog(12745): [PatchStore] createDisableExceptionQarthFile
I/QarthLog(12745): [PatchStore] create disable file for com.alephexpress.mobile uid is 11259
E/AndroidRuntime(12745): FATAL EXCEPTION: main
E/AndroidRuntime(12745): Process: com.appName.mobile, PID: 12745
E/AndroidRuntime(12745): java.lang.RuntimeException: Error receiving broadcast Intent { act=com.google.android.gms.auth.api.phone.SMS_RETRIEVED flg=0x200010 pkg=com.alephexpress.mobile (has extras) } in com.google.android.gms.internal.firebase-auth-api.zzady@3dddae9
E/AndroidRuntime(12745): at android.app.LoadedApk$ReceiverDispatcher$Args.lambda$getRunnable$0$LoadedApk$ReceiverDispatcher$Args(LoadedApk.java:1670)
E/AndroidRuntime(12745): at android.app.-$$Lambda$LoadedApk$ReceiverDispatcher$Args$_BumDX2UKsnxLVrE6UJsJZkotuA.run(Unknown Source:2)
E/AndroidRuntime(12745): at android.os.Handler.handleCallback(Handler.java:888)
E/AndroidRuntime(12745): at android.os.Handler.dispatchMessage(Handler.java:100)
E/AndroidRuntime(12745): at android.os.Looper.loop(Looper.java:213)
E/AndroidRuntime(12745): at android.app.ActivityThread.main(ActivityThread.java:8178)
E/AndroidRuntime(12745): at java.lang.reflect.Method.invoke(Native Method)
E/AndroidRuntime(12745): at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:513)
E/AndroidRuntime(12745): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1101)
E/AndroidRuntime(12745): Caused by: java.lang.NullPointerException: Attempt to invoke interface method 'int java.lang.CharSequence.length()' on a null object reference
E/AndroidRuntime(12745): at java.util.regex.Matcher.reset(Matcher.java:280)
E/AndroidRuntime(12745): at java.util.regex.Matcher.<init>(Matcher.java:186)
E/AndroidRuntime(12745): at java.util.regex.Pattern.matcher(Pattern.java:1034)
E/AndroidRuntime(12745): at com.google.android.gms.internal.firebase-auth-api.zzadu.zza(com.google.firebase:firebase-auth@@22.3.0:3)
E/AndroidRuntime(12745): at com.google.android.gms.internal.firebase-auth-api.zzady.onReceive(com.google.firebase:firebase-auth@@22.3.0:13)
E/AndroidRuntime(12745): at android.app.LoadedApk$ReceiverDispatcher$Args.lambda$getRunnable$0$LoadedApk$ReceiverDispatcher$Args(LoadedApk.java:1660)
E/AndroidRuntime(12745): ... 8 more
W/hexpress.mobile(12745): type=1400 audit(0.0:598689): avc: granted { getattr } for pid=12745 name="/" dev="sdcardfs" ino=1278 scontext=u:r:untrusted_app:s0:c235,c260,c512,c768 tcontext=u:object_r:sdcardfs:s0 tclass=filesystem
I/Process (12745): Sending signal. PID: 12745 SIG: 9
Lost connection to device.
to input sms code i use pinput package
Pinput(
length: 6,
androidSmsAutofillMethod:
AndroidSmsAutofillMethod.smsUserConsentApi,
submittedPinTheme: pinTheme(
signUpSmsTimerWatch.errorText == null
? AppColorsV3.syslightonsurface
: AppColorsV3.syslighterror),
defaultPinTheme: pinTheme(AppColorsV3.syslightoutline),
focusedPinTheme: pinTheme(AppColorsV3.syslightprimary),
errorPinTheme: pinTheme(AppColorsV3.syslighterror),
hapticFeedbackType: HapticFeedbackType.mediumImpact,
errorTextStyle: const TextStyle(color: Colors.red),
errorText: signUpSmsTimerWatch.errorText,
closeKeyboardWhenCompleted: true,
pinputAutovalidateMode: PinputAutovalidateMode.onSubmit,
mainAxisAlignment: MainAxisAlignment.spaceAround,
onCompleted: (value) {....}
autofocus: true,
),
@guvanch07 pinput is a third party package. I tried your code sample above in the plugin example, with which I wasn't able to replicate the reported error. Can you try the same and check if issue persists using plugin example ?
did you hide timeout:
param in the code https://github.com/firebase/flutterfire/issues/12170#issuecomment-1900213993?
if you didn't hide, please hide the line timeout: const Duration(seconds: 0)
and try again
timeout
is optional
and need to test only android devises where has a autofill functionality
@guvanch07
Looking at the error log, the crash seems to be occuring in native pointing to the sms api act=com.google.android.gms.auth.api.phone.SMS_RETRIEVED
Is it possible for you to try and replicate the behavior only using the plugin example (without pinput package) and by commenting out the timeout
property as you mentioned above ?
yes, it looks like Pinput package's problem i found issue that is related to the error i got https://github.com/Tkko/Flutter_Pinput/issues/105
Closing based on above, as not flutterfire issue.
Bug report
Describe the bug Android app crash when receive an sms code if you haven't set a timeout
RuntimeException
Error receiving broadcast Intent { act=com.google.android.gms.auth.api.phone.SMS_RETRIEVED flg=0x200010 pkg=com.alephexpress.mobile (has extras) } in com.google.android.gms.internal.firebase-auth-api.zzady@a70f551
Steps to reproduce
Create new firebase project and add phone provider call verifyPhoneNumber method from FirebaseAuth and don't set timeout
Steps to reproduce the behavior:
Expected behavior
Recive sms code and paste it to textfilds
Sample project
Providing a minimal example project which demonstrates the bug in isolation from your main App greatly enhances the chance of a timely fix. Please link to the public repository URL.
Additional context
Add any other context about the problem here.
Flutter doctor
Run
flutter doctor
and paste the output below:Click To Expand
``` [✓] Flutter (Channel stable, 3.16.5, on macOS 13.5 22G74 darwin-arm64, locale en-BY) [✓] Android toolchain - develop for Android devices (Android SDK version 33.0.2) [✓] Xcode - develop for iOS and macOS (Xcode 15.1) [✓] Chrome - develop for the web [✓] Android Studio (version 2022.2) [✓] VS Code (version 1.85.1) [✓] Connected device (4 available) [✓] Network resources • No issues found! ```Flutter dependencies
Run
flutter pub deps -- --style=compact
and paste the output below:Click To Expand
``` freezed_annotation: ^2.4.1 flutter_bloc: ^8.1.3 bloc_concurrency: ^0.2.2 intl: ^0.18.1 slang: ^3.26.2 slang_flutter: ^3.26.2 shared_preferences: ^2.2.1 flutter_secure_storage: ^9.0.0 sentry_flutter: ^7.13.2 sentry_dio: ^7.13.2 flutter_svg: ^2.0.9 crypto: ^3.0.3 get_it: ^7.6.4 email_validator: ^2.1.17 mask_text_input_formatter: ^2.7.0 cupertino_icons: ^1.0.6 pull_to_refresh: ^2.0.0 device_preview: ^1.1.0 url_launcher: ^6.2.2 permission_handler: ^11.1.0 fast_cached_network_image: ^1.2.0 modal_bottom_sheet: ^3.0.0-pre keyboard_actions: ^4.2.0 flutter_staggered_grid_view: ^0.7.0 photo_view: ^0.14.0 reorderable_grid: ^1.0.10 uuid: ^3.0.7 webview_flutter: ^4.4.2 collection: ^1.17.2 logger: ^2.0.2 flutter_slidable: ^3.0.1 share_plus: ^7.0.2 grouped_list: ^5.1.2 idkit_inputformatters: ^0.0.1 jwt_decoder: ^2.0.1 jiffy: ^6.2.1 package_info_plus: ^5.0.1 regexed_validator: ^2.0.0+1 google_fonts: ^6.0.0 cupertino_will_pop_scope: ^1.2.1 dotted_border: ^2.1.0 dotted_decoration: ^2.0.0 firebase_messaging: ^14.7.9 flutter_local_notifications: ^16.2.0 firebase_analytics: ^10.7.4 shimmer: ^3.0.0 go_router: ^12.1.1 flutter_facebook_auth: ^6.0.3 ios_willpop_transition_theme: ^0.0.6 badges: ^3.1.2 freshchat_sdk: ^0.10.10 retry: ^3.1.2 slide_action: ^0.0.2 loop_page_view: ^1.2.5 path_provider: ^2.1.1 video_thumbnail: ^0.5.3 video_player: ^2.8.1 flick_video_player: ^0.7.0 visibility_detector: ^0.4.0+2 uni_links: ^0.5.1 app_tracking_transparency: ^2.0.4 connectivity_plus: ^5.0.2 flutter_linkify: ^6.0.0 device_info_plus: ^9.0.1 flutter_inappwebview: git: url: https://github.com/LuckyWins/flutter_inappwebview.git ref: v5.7.2+3-xcode-fix flutter_image_compress: ^2.1.0 path: ^1.8.3 pinput: ^3.0.1 firebase_auth: ^4.15.3 # phone_numbers_parser: ^8.0.0 // maybe will use facebook_app_events: ^0.19.0 audio_waveforms: ^1.0.4 any_link_preview: ^3.0.1 audio_session: ^0.1.18 multi_split_view: ^2.4.0 wechat_assets_picker: 9.0.0-dev.2 lottie: ^2.7.0 upgrader: ^8.3.0 appsflyer_sdk: ^6.12.2 flutter_smartlook: ^4.1.14 # ffmpeg_kit_flutter: ^6.0.3 ffmpeg_kit_flutter_audio: ^6.0.3 chucker_flutter: ^1.6.0 flutter_libphonenumber: ^2.1.5 sliver_tools: ^0.2.12 flex_color_picker: ^3.3.0 clock: ^1.1.1 ```