Closed e-e closed 3 years ago
Hi @e-e
If you flutter upgrade
to the latest stable and remove the native SDK version overrides from android/app/build.gradle
implementation platform('com.google.firebase:firebase-bom:28.4.1')
implementation 'com.google.firebase:firebase-auth:19.3.2'
implementation "com.google.firebase:firebase-messaging:20.2.4"
does it still reproduce? Thank you
@markusaksli-nc thank you for the suggestion, I am in the process of testing this out and will report back
@markusaksli-nc I tried making the changes you suggested. I was able to get the simulators on my machine to work properly where they weren't before, but test builds installed by other users on real devices are still not working. Also, on another devs computer the simulators are not working either.
I just took a look at our Sentry account, and see the following that corresponds with when I think the other users were trying to load the app:
verificationFailed: [code - app-not-authorized][message - This app is not authorized to use Firebase Authentication. Please verify that the correct package name and SHA-1 are configured in the Firebase Console. [ A safety_net_token was passed, but no matching SHA-256 was registered in the Firebase console. Please make sure that this application’s packageName/SHA256 pair is registered in the Firebase Console. ]]
You just need them to add their SHA-1 and SHA-256 keys to Firebase Console https://firebase.flutter.dev/docs/installation/android#generating-a-firebase-project-configuration-file
When I run that, I get a very long list of different keys:
> Task :app:signingReport
Variant: releaseUnitTest
Config: release
<KEYS>...
----------
Variant: debug
Config: debug
Store: /Users/eke/.android/debug.keystore
<KEYS>...
----------
Variant: debugUnitTest
Config: debug
<KEYS>...
----------
Variant: release
Config: release
<KEYS>...
----------
Variant: profile
Config: debug
<KEYS>...
----------
Variant: debugAndroidTest
Config: debug
<KEYS>...
----------
Variant: profileUnitTest
Config: debug
<KEYS>...
----------
> Task :camera:signingReport
Variant: releaseUnitTest
Config: none
----------
Variant: debugUnitTest
Config: debug
<KEYS>...
----------
Variant: profileUnitTest
Config: none
----------
Variant: debugAndroidTest
Config: debug
<KEYS>...
----------
> Task :device_info:signingReport
Variant: debugUnitTest
Config: debug
<KEYS>...
----------
Variant: debugAndroidTest
Config: debug
<KEYS>...
----------
Variant: releaseUnitTest
Config: none
<KEYS>...
----------
Variant: profileUnitTest
Config: none
<KEYS>...
----------
....
Which should be added to the Firebase Console?
The SHA-1 belonging to debugAndroidTest
as mentioned in the documentation. If you notice most of the output is actually the same key
I think this issue has been resolved. I think the original issue was resolved by your initial suggestion, then the next issue was resolved by following the instructions as outlined here. We were missing the play store signing credentials in our Firebase app settings. Thank you for your help, it is very much appreciated.
Closing this as resolved based on above comment.
Bug report
I know there are a few other issues with this same error, but none of the solutions have yet worked for me. Most of them seem to have been some form of connection issues, and since I've tried this on multiple real devices with different connections, I've ruled that out. This issue only happens on devices that have not yet successfully initialized Firebase before. For example, if I clear the cache and uninstall on my personal device (pixel 5), I can reinstall from Android Studio and it all works fine. But attempting on a friends phone for the first time fails with the following:
Steps to reproduce
Steps to reproduce the behavior:
Expected behavior
Token should be retrieved and app should work?
Sample project
n/a
Additional context
Flutter doctor
Click To Expand
``` Doctor summary (to see all details, run flutter doctor -v): [✓] Flutter (Channel stable, 2.2.3, on macOS 11.3.1 20E241 darwin-x64, locale en-US) [✓] Android toolchain - develop for Android devices (Android SDK version 30.0.3) [✓] Xcode - develop for iOS and macOS [✓] Chrome - develop for the web [✓] Android Studio (version 2020.3) [✓] VS Code (version 1.60.1) [✓] Connected device (3 available) ```Flutter dependencies
Click To Expand
``` Dart SDK 2.13.4 Flutter SDK 2.2.3 twibs_flutter 1.0.0+8 dependencies: - animations 1.1.2 [flutter] - ansicolor 1.1.1 - app_tracking_transparency 2.0.1 [flutter] - auto_route 0.6.9 [flutter meta] - badges 2.0.1 [flutter] - cached_network_image 3.0.0-nullsafety [flutter flutter_cache_manager octo_image] - carousel_slider 4.0.0-nullsafety.0 [flutter] - community_material_icon 5.9.55 [flutter] - country_code_picker 2.0.2 [flutter modal_bottom_sheet collection universal_platform] - cupertino_icons 1.0.2 - firebase_auth 3.0.1 [firebase_auth_platform_interface firebase_auth_web firebase_core firebase_core_platform_interface flutter meta] - firebase_core 1.6.0 [firebase_core_platform_interface firebase_core_web flutter meta] - firebase_dynamic_links 2.0.7 [firebase_core flutter] - firebase_messaging 10.0.7 [firebase_core firebase_core_platform_interface firebase_messaging_platform_interface firebase_messaging_web flutter meta] - firebase_storage 8.0.0 [firebase_core firebase_core_platform_interface firebase_storage_platform_interface firebase_storage_web flutter] - flutter 0.0.0 [characters collection meta typed_data vector_math sky_engine] - flutter_animated_dialog 1.2.0 [flutter] - flutter_dotenv 5.1.0 [flutter] - flutter_emoji_keyboard 0.1.3 [flutter device_info] - flutter_hooks 0.16.0 [flutter] - flutter_icons 1.1.0 [flutter] - flutter_localizations 0.0.0 [flutter intl characters clock collection meta path typed_data vector_math] - flutter_map 0.13.1 [async collection flutter http intl latlong2 meta positioned_tap_detector_2 proj4dart transparent_image tuple vector_math] - flutter_spinkit 5.0.0 [flutter] - flutter_typeahead 3.1.3 [flutter flutter_keyboard_visibility] - geolocator 7.0.1 [flutter geolocator_platform_interface geolocator_web] - get_it 7.2.0 [async collection] - google_fonts 2.1.0 [flutter http path_provider crypto] - http 0.13.3 [async http_parser meta path pedantic] - image_picker 0.7.2 [flutter flutter_plugin_android_lifecycle image_picker_platform_interface] - intl 0.17.0 [clock path] - logger 1.0.0 - multi_image_picker 4.8.00 [flutter meta] - observable_ish 3.0.0 [collection] - package_info 2.0.2 [flutter] - pin_code_fields 7.0.0-nullsafety [flutter] - reorderables 0.3.2 [flutter] - sentry_flutter 5.1.0 [flutter flutter_web_plugins sentry package_info_plus] - sliding_up_panel 1.0.2 [flutter] - stacked 2.2.3 [flutter get_it meta provider collection universal_io] - stacked_hooks 0.1.4 [flutter flutter_hooks provider] - stacked_services 0.8.13 [flutter get] - uuid 3.0.1 [crypto] - web_socket_channel 1.2.0 [async crypto stream_channel] - wechat_assets_picker 5.5.6 [flutter extended_image photo_manager provider video_player] - wechat_camera_picker 2.2.0 [flutter camera device_info path path_provider photo_manager video_player] dev dependencies: - auto_route_generator 0.6.10 [build source_gen analyzer path build_runner auto_route] - build_runner 1.11.5 [args async build build_config build_daemon build_resolvers build_runner_core code_builder collection crypto dart_style glob graphs http_multi_server io js logging meta mime path pedantic pool pub_semver pubspec_parse shelf shelf_web_socket stack_trace stream_transform timing watcher web_socket_channel yaml] - flutter_launcher_icons 0.9.2 [args image path yaml] - flutter_test 0.0.0 [flutter test_api path fake_async clock stack_trace vector_math async boolean_selector characters charcode collection matcher meta source_span stream_channel string_scanner term_glyph typed_data] transitive dependencies: - _fe_analyzer_shared 17.0.0 [meta] - analyzer 1.1.0 [_fe_analyzer_shared args cli_util collection convert crypto glob meta package_config path pub_semver source_span watcher yaml] - archive 3.1.2 [crypto path] - args 2.3.0 - async 2.6.1 [meta collection] - boolean_selector 2.1.0 [source_span string_scanner] - build 1.6.3 [analyzer async convert crypto glob logging meta path] - build_config 0.4.6 [checked_yaml json_annotation meta path pubspec_parse yaml] - build_daemon 2.1.8 [built_collection built_value http_multi_server logging pedantic path pool shelf shelf_web_socket stream_transform watcher web_socket_channel] - build_resolvers 1.5.4 [analyzer build crypto graphs logging meta path package_config pool pub_semver] - build_runner_core 6.1.10 [async build build_config build_resolvers collection convert crypto glob graphs logging meta path package_config pedantic pool timing watcher yaml] - built_collection 5.0.0 - built_value 8.0.0 [built_collection collection fixnum] - camera 0.8.1+3 [camera_platform_interface flutter pedantic quiver] - camera_platform_interface 2.0.1 [flutter meta plugin_platform_interface cross_file stream_transform] - characters 1.1.0 - charcode 1.2.0 - checked_yaml 1.0.4 [json_annotation source_span yaml] - cli_util 0.3.0 [meta path] - clock 1.1.0 - code_builder 3.6.0 [built_collection built_value collection matcher meta] - collection 1.15.0 - convert 3.0.0 [typed_data] - cross_file 0.3.1+1 [flutter meta] - crypto 3.0.0 [collection typed_data] - dart_style 1.3.14 [analyzer args path pub_semver source_span] - device_info 2.0.0 [flutter device_info_platform_interface] - device_info_platform_interface 2.0.1 [flutter meta plugin_platform_interface] - extended_image 4.1.0 [extended_image_library flutter meta] - extended_image_library 3.1.0 [crypto flutter http_client_helper path path_provider] - fake_async 1.2.0 [clock collection] - ffi 1.0.0 - file 6.1.0 [meta path] - firebase_auth_platform_interface 6.0.0 [firebase_core flutter meta plugin_platform_interface] - firebase_auth_web 3.0.0 [firebase_auth_platform_interface firebase_core firebase_core_web flutter flutter_web_plugins http_parser intl js meta] - firebase_core_platform_interface 4.0.1 [collection flutter meta plugin_platform_interface] - firebase_core_web 1.1.0 [firebase_core_platform_interface flutter flutter_web_plugins js meta] - firebase_messaging_platform_interface 3.0.5 [firebase_core flutter meta plugin_platform_interface] - firebase_messaging_web 2.0.5 [firebase_core firebase_core_web firebase_messaging_platform_interface flutter flutter_web_plugins js meta] - firebase_storage_platform_interface 2.0.0 [collection firebase_core flutter meta plugin_platform_interface] - firebase_storage_web 1.0.0 [async firebase_core firebase_core_web firebase_storage_platform_interface flutter flutter_web_plugins http js meta] - fixnum 1.0.0 - flutter_blurhash 0.5.4-nullsafety.0 [flutter meta pedantic] - flutter_cache_manager 3.0.0-nullsafety.1 [clock collection file flutter http image path path_provider pedantic rxdart sqflite uuid] - flutter_keyboard_visibility 5.0.1 [meta flutter_keyboard_visibility_platform_interface flutter_keyboard_visibility_web flutter] - flutter_keyboard_visibility_platform_interface 2.0.0 [flutter meta plugin_platform_interface] - flutter_keyboard_visibility_web 2.0.0 [flutter_keyboard_visibility_platform_interface flutter_web_plugins flutter] - flutter_plugin_android_lifecycle 2.0.0 [flutter] - flutter_web_plugins 0.0.0 [flutter js characters collection meta typed_data vector_math] - geolocator_platform_interface 2.0.0 [flutter plugin_platform_interface vector_math meta] - geolocator_web 2.0.1 [flutter flutter_web_plugins geolocator_platform_interface] - get 4.3.4 [flutter] - glob 2.0.0 [async collection file path pedantic string_scanner] - graphs 0.2.0 - http_client_helper 2.0.2 [http] - http_multi_server 2.2.0 [async] - http_parser 4.0.0 [charcode collection source_span string_scanner typed_data] - image 3.0.4 [archive meta xml] - image_picker_platform_interface 2.0.1 [flutter meta http plugin_platform_interface] - io 0.3.5 [meta path string_scanner] - js 0.6.3 - json_annotation 4.0.0 - latlong2 0.8.0 [intl] - lists 1.0.0 [meta] - logging 0.11.4 - matcher 0.12.10 [stack_trace] - meta 1.3.0 - mgrs_dart 2.0.0 [unicode] - mime 1.0.0 - modal_bottom_sheet 2.0.0 [flutter] - nested 1.0.0 [flutter] - octo_image 1.0.0-nullsafety.1 [flutter flutter_blurhash] - package_config 2.0.0 [path] - package_info_plus 1.0.3 [flutter package_info_plus_platform_interface package_info_plus_linux package_info_plus_macos package_info_plus_windows package_info_plus_web] - package_info_plus_linux 1.0.2 [package_info_plus_platform_interface flutter path] - package_info_plus_macos 1.1.1 [flutter] - package_info_plus_platform_interface 1.0.1 [flutter meta plugin_platform_interface] - package_info_plus_web 1.0.2 [http package_info_plus_platform_interface flutter flutter_web_plugins meta] - package_info_plus_windows 1.0.2 [package_info_plus_platform_interface ffi flutter win32] - path 1.8.0 - path_provider 2.0.1 [flutter path_provider_platform_interface path_provider_macos path_provider_linux path_provider_windows] - path_provider_linux 2.0.0 [path xdg_directories path_provider_platform_interface flutter] - path_provider_macos 2.0.0 [flutter] - path_provider_platform_interface 2.0.1 [flutter meta platform plugin_platform_interface] - path_provider_windows 2.0.0 [path_provider_platform_interface meta path flutter ffi win32] - pedantic 1.11.0 - petitparser 4.0.2 [meta] - photo_manager 1.2.2 [flutter] - platform 3.0.0 - plugin_platform_interface 2.0.0 [meta] - pool 1.5.0 [async stack_trace] - positioned_tap_detector_2 1.0.0 [flutter] - process 4.1.0 [file path platform] - proj4dart 2.0.0 [mgrs_dart wkt_parser meta] - provider 5.0.0 [collection flutter nested] - pub_semver 2.0.0 [collection] - pubspec_parse 0.1.8 [checked_yaml json_annotation pub_semver yaml] - quiver 3.0.1 [matcher] - rxdart 0.26.0 - sentry 5.1.0 [http meta stack_trace uuid] - shelf 1.0.0 [async collection http_parser path stack_trace stream_channel] - shelf_web_socket 0.2.4+1 [shelf stream_channel web_socket_channel] - sky_engine 0.0.99 - source_gen 0.9.10+3 [analyzer async build dart_style glob meta path pedantic source_span] - source_span 1.8.1 [collection path term_glyph] - sqflite 2.0.0+2 [flutter sqflite_common path] - sqflite_common 2.0.0+1 [synchronized path meta] - stack_trace 1.10.0 [path] - stream_channel 2.1.0 [async] - stream_transform 2.0.0 - string_scanner 1.1.0 [charcode source_span] - synchronized 3.0.0 - term_glyph 1.2.0 - test_api 0.3.0 [async boolean_selector collection meta path source_span stack_trace stream_channel string_scanner term_glyph matcher] - timing 0.1.1+3 [json_annotation] - transparent_image 2.0.0 - tuple 2.0.0 [quiver] - typed_data 1.3.0 [collection] - unicode 0.3.0 [lists] - universal_io 2.0.4 [collection crypto meta typed_data] - universal_platform 1.0.0+1 - vector_math 2.1.0 - video_player 2.1.6 [flutter flutter_test meta video_player_platform_interface video_player_web] - video_player_platform_interface 4.1.0 [flutter meta flutter_test] - video_player_web 2.0.1 [flutter flutter_web_plugins meta video_player_platform_interface] - watcher 1.0.0 [async path pedantic] - win32 2.0.0 [ffi] - wkt_parser 2.0.0 - xdg_directories 0.2.0 [meta path process] ```android/build.gradle:
Click To Expand
```gradle buildscript { ext.kotlin_version = '1.3.50' repositories { google() jcenter() } dependencies { classpath 'com.android.tools.build:gradle:3.5.0' classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" classpath 'com.google.gms:google-services:4.3.10' } } allprojects { repositories { google() jcenter() } } rootProject.buildDir = '../build' subprojects { project.buildDir = "${rootProject.buildDir}/${project.name}" } subprojects { project.evaluationDependsOn(':app') } task clean(type: Delete) { delete rootProject.buildDir } ```android/app/build.gradle:
Click To Expand
```gradle def localProperties = new Properties() def localPropertiesFile = rootProject.file('local.properties') if (localPropertiesFile.exists()) { localPropertiesFile.withReader('UTF-8') { reader -> localProperties.load(reader) } } def flutterRoot = localProperties.getProperty('flutter.sdk') if (flutterRoot == null) { throw new GradleException("Flutter SDK not found. Define location with flutter.sdk in the local.properties file.") } def flutterVersionCode = localProperties.getProperty('flutter.versionCode') if (flutterVersionCode == null) { flutterVersionCode = '1' } def flutterVersionName = localProperties.getProperty('flutter.versionName') if (flutterVersionName == null) { flutterVersionName = '1.0' } apply plugin: 'com.android.application' apply plugin: 'com.google.gms.google-services' apply plugin: 'kotlin-android' apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle" def keystoreProperties = new Properties() def keystorePropertiesFile = rootProject.file('key.properties') if (keystorePropertiesFile.exists()) { keystoreProperties.load(new FileInputStream(keystorePropertiesFile)) } android { compileSdkVersion 30 sourceSets { main.java.srcDirs += 'src/main/kotlin' } lintOptions { disable 'InvalidPackage' } defaultConfig { // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html). applicationId "io.twibs.twibs" minSdkVersion 21 targetSdkVersion 30 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 { release { signingConfig signingConfigs.release } } } flutter { source '../..' } dependencies { implementation platform('com.google.firebase:firebase-bom:28.4.1') implementation 'com.google.firebase:firebase-analytics' // implementation 'com.google.firebase:firebase-analytics-ktx' implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" implementation 'com.google.firebase:firebase-auth:19.3.2' implementation "com.google.firebase:firebase-messaging:20.2.4" implementation 'com.android.support:multidex:1.0.3' } ``` code snippet where the error is currently thrown, although it fails at the next firebase service call if i comment this out: ```dart _firebaseMessaging = FirebaseMessaging.instance; settings = await _firebaseMessaging.requestPermission( alert: true, announcement: true, badge: true, sound: true, ); token = await _firebaseMessaging.getToken(); ```