firebase / flutterfire

🔥 A collection of Firebase plugins for Flutter apps.
https://firebase.google.com/docs/flutter/setup
BSD 3-Clause "New" or "Revised" License
8.7k stars 3.97k forks source link

🐛 [firebase_messaging] Build fails trying to upgrade from 7.0.3 to 8.0.0-dev.14 #5000

Closed yanivshaked closed 3 years ago

yanivshaked commented 3 years ago

Bug report

Getting the following build errors:

e: C:\dev\12Tech12\git\client\tw_app\android\app\src\main\kotlin\com\twtech\twelve\Application.kt: (6, 27): Unresolved reference: firebasemessaging
e: C:\dev\12Tech12\git\client\tw_app\android\app\src\main\kotlin\com\twtech\twelve\Application.kt: (15, 5): Unresolved reference: FlutterFirebaseMessagingService
e: C:\dev\12Tech12\git\client\tw_app\android\app\src\main\kotlin\com\twtech\twelve\FirebaseCloudMessagingPluginRegistrant.kt: (4, 27): Unresolved reference: firebasemessaging
e: C:\dev\12Tech12\git\client\tw_app\android\app\src\main\kotlin\com\twtech\twelve\FirebaseCloudMessagingPluginRegistrant.kt: (12, 7): Unresolved reference: FirebaseMessagingPlugin  

Steps to reproduce

Previous working dependencies are:

  firebase_core: ^0.5.2+1
  firebase_auth: ^0.18.3+1
  firebase_storage: ^5.1.0
  firebase_messaging: ^7.0.3
  firebase_crashlytics: ^0.2.3+1
  firebase_analytics: ^6.3.0

Updated dependencies to:

  firebase_core: ^0.7.0
  firebase_auth: ^0.20.0+1
  firebase_storage: ^7.0.0
  firebase_messaging: ^8.0.0-dev.14
  firebase_crashlytics: ^0.4.0+1
  firebase_analytics: ^7.0.1

and updated the relevant calls to FirebaseMessaging (to use the static calls instead). When trying to build (flutter run / flutter build apk) getting the error message above.

flutter doctor -v results:

Click To Expand ``` [√] Flutter (Channel stable, 1.22.4, on Microsoft Windows [Version 10.0.19041.746], locale en-IL) • Flutter version 1.22.4 at C:\src\flutter • Framework revision 1aafb3a8b9 (3 months ago), 2020-11-13 09:59:28 -0800 • Engine revision 2c956a31c0 • Dart version 2.10.4 [√] Android toolchain - develop for Android devices (Android SDK version 30.0.2) • Android SDK at C:\Users\shake\AppData\Local\Android\sdk • Platform android-30, build-tools 30.0.2 • Java binary at: C:\Program Files\Android\Android Studio\jre\bin\java • Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b01) • All Android licenses accepted. [!] Android Studio (version 4.1.0) • Android Studio at C:\Program Files\Android\Android Studio X Flutter plugin not installed; this adds Flutter specific functionality. X Dart plugin not installed; this adds Dart specific functionality. • Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b01) [√] VS Code (version 1.53.0) • VS Code at C:\Users\shake\AppData\Local\Programs\Microsoft VS Code • Flutter extension version 3.19.0 [√] Connected device (1 available) • KB2003 (mobile) • 84cda63c • android-arm64 • Android 11 (API 30) ```

Flutter dependencies

Run flutter pub deps -- --style=compact and paste the output below:

Click To Expand ``` Dart SDK 2.10.4 Flutter SDK 1.22.4 tw_app 0.10.116+2290 dependencies: - ansicolor 1.1.1 - app_settings 4.0.4 [flutter] - assets_audio_player 2.0.13+1 [flutter rxdart uuid http path_provider assets_audio_player_web] - audioplayers 0.17.0 [uuid path_provider flutter flutter_web_plugins] - autocomplete_textfield 1.7.3 [flutter] - bubble 1.1.9+1 [flutter] - cached_network_image 2.4.1 [flutter flutter_cache_manager octo_image] - charset_converter 1.0.3 [flutter] - connectivity 2.0.2 [flutter meta connectivity_platform_interface connectivity_macos connectivity_for_web] - contacts_service 0.4.6 [flutter collection quiver] - dashed_circle 0.0.1 [flutter] - device_info 1.0.0 [flutter device_info_platform_interface] - devicelocale 0.3.3 [flutter] - equatable 1.2.5 [collection meta] - expandable 4.1.4 [flutter] - facebook_app_events 0.8.1 [flutter] - file_picker 2.1.0 [flutter flutter_web_plugins flutter_plugin_android_lifecycle plugin_platform_interface] - firebase_analytics 7.0.1 [meta flutter firebase_core firebase_analytics_web firebase_analytics_platform_interface] - firebase_auth 0.20.0+1 [meta firebase_core firebase_core_platform_interface firebase_auth_platform_interface firebase_auth_web flutter] - firebase_core 0.7.0 [firebase_core_platform_interface flutter quiver meta firebase_core_web] - firebase_crashlytics 0.4.0+1 [flutter stack_trace firebase_core firebase_core_platform_interface firebase_crashlytics_platform_interface] - firebase_messaging 8.0.0-dev.14 [meta flutter firebase_core firebase_core_platform_interface firebase_messaging_platform_interface firebase_messaging_web] - firebase_storage 7.0.0 [flutter firebase_core firebase_core_platform_interface firebase_storage_web firebase_storage_platform_interface quiver] - fixnum 0.10.11 - flushbar 1.10.4 [flutter] - flutter 0.0.0 [characters collection meta typed_data vector_math sky_engine] - flutter_absolute_path 1.0.6 [flutter] - flutter_better_camera 0.6.1 [flutter] - flutter_bloc 6.1.1 [flutter bloc provider] - flutter_cached_pdfview 0.3.1 [flutter flutter_pdfview flutter_cache_manager path_provider path] - flutter_datetime_picker 1.4.0 [flutter] - flutter_html 1.1.1 [html csslib css_colors video_player chewie webview_flutter chewie_audio flutter_svg flutter] - flutter_image_compress 0.7.0 [flutter] - flutter_local_notifications 3.0.1+6 [flutter platform flutter_local_notifications_platform_interface timezone] - flutter_localizations 0.0.0 [flutter intl characters collection meta path typed_data vector_math] - flutter_mailer 1.0.1 [flutter] - flutter_native_text_input 0.1.2 [flutter] - flutter_secure_storage 3.3.5 [meta flutter] - flutter_sim_country_code 0.0.3 [flutter] - flutter_slidable 0.5.7 [flutter] - flutter_sound_lite 6.4.5+1 [path_provider logger intl recase uuid provider flutter_spinkit path synchronized flutter flutter_sound_platform_interface flutter_sound_web] - flutter_svg 0.19.1 [flutter meta path_drawing vector_math xml] - flutter_typeahead 1.9.1 [flutter flutter_keyboard_visibility] - flutter_xlider 3.4.0 [flutter] - fluttertoast 7.1.6 [flutter flutter_web_plugins] - get_it 5.0.1 [async meta] - html_unescape 1.0.2 - http 0.12.2 [http_parser path pedantic] - image 2.1.19 [archive xml meta] - intl 0.16.1 [path] - ios_app_group 1.0.2 [flutter] - json_serializable 3.5.0 [analyzer build build_config json_annotation meta path source_gen] - multi_image_picker 4.7.15 [flutter meta] - mutex 1.1.0 - native_device_orientation 0.4.3 [flutter] - ntp 1.0.7 [universal_io] - open_file 3.0.3 [flutter ffi] - package_info 0.4.3+2 [flutter] - path_provider 1.6.24 [flutter path_provider_platform_interface path_provider_macos path_provider_linux path_provider_windows] - percent_indicator 2.1.8 [flutter] - permission_handler 5.0.1+1 [flutter meta permission_handler_platform_interface] - phone_number 0.8.1 [meta flutter] - photo_view 0.10.3 [flutter] - pin_code_fields 6.0.1 [flutter] - pointycastle 2.0.0 - receive_sharing_intent 1.4.2 [flutter] - reorderables 0.3.2 [flutter] - rxdart 0.24.1 - scroll_to_index 1.0.6 [flutter] - scrollable_positioned_list 0.1.8 [flutter meta] - share_extend 1.1.9 [meta flutter] - shared_preferences_app_group_ios 0.0.3 [flutter] - sliding_sheet 0.4.1 [flutter] - sound_mode 0.2.2 [flutter] - sprintf 5.0.0 - sqfentity 1.4.0+3 [flutter sqflite synchronized path sqfentity_gen sqflite_common_ffi] - sqfentity_gen 1.4.0+2 [build source_gen] - sqflite 1.3.2+1 [flutter sqflite_common path] - sticky_headers 0.1.8+1 [flutter meta] - tuple 1.0.3 [quiver] - uni_links 0.4.0 [flutter] - url_launcher 5.7.10 [flutter url_launcher_platform_interface url_launcher_web url_launcher_linux url_launcher_macos url_launcher_windows] - url_launcher_ios 0.0.2 [flutter] - uuid 2.2.2 [crypto convert] - vibration 1.7.3 [flutter vibration_web] - video_compress 2.1.1 [flutter] - video_player 1.0.1 [meta video_player_platform_interface video_player_web flutter] - video_thumbnail 0.2.5 [flutter] - visibility_detector 0.1.5 [flutter] - web_socket_channel 1.1.0 [async crypto stream_channel] dev dependencies: - build_runner 1.10.6 [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] - build_verify 1.1.1 [path test] - dependency_validator 2.0.1 [args build_config checked_yaml glob json_annotation logging package_config path pub_semver pubspec_parse yaml] - flutter_driver 0.0.0 [file json_rpc_2 meta path web_socket_channel vm_service_client webdriver flutter flutter_test fuchsia_remote_debug_protocol archive args async boolean_selector characters charcode clock collection convert crypto fake_async matcher platform process pub_semver source_span stack_trace stream_channel string_scanner sync_http term_glyph test_api typed_data vector_math] - flutter_launcher_icons 0.8.1 [image args yaml path] - 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] - test 1.16.0-nullsafety.5 [analyzer async boolean_selector coverage http http_multi_server io js node_preamble package_config path pedantic pool shelf shelf_packages_handler shelf_static shelf_web_socket source_span stack_trace stream_channel typed_data web_socket_channel webkit_inspection_protocol yaml test_api test_core] transitive dependencies: - _fe_analyzer_shared 12.0.0 [meta] - analyzer 0.40.6 [_fe_analyzer_shared args cli_util collection convert crypto glob meta package_config path pub_semver source_span watcher yaml] - archive 2.0.13 [crypto args path] - args 1.6.0 - assets_audio_player_web 2.0.13+1 [flutter flutter_web_plugins] - async 2.5.0-nullsafety.1 [collection] - bloc 6.1.0 [meta] - boolean_selector 2.1.0-nullsafety.1 [source_span string_scanner] - build 1.5.1 [analyzer async convert crypto logging meta path glob] - build_config 0.4.3 [checked_yaml json_annotation meta path pubspec_parse yaml] - build_daemon 2.1.4 [built_collection built_value http_multi_server logging pedantic path pool shelf shelf_web_socket stream_transform watcher web_socket_channel] - build_resolvers 1.4.3 [analyzer build crypto graphs logging meta path package_config pool pub_semver] - build_runner_core 6.1.1 [async build build_config build_resolvers collection convert crypto glob graphs json_annotation logging meta path package_config pedantic pool timing watcher yaml] - built_collection 4.3.2 [collection quiver] - built_value 7.1.0 [built_collection collection fixnum quiver] - characters 1.1.0-nullsafety.3 - charcode 1.2.0-nullsafety.1 - checked_yaml 1.0.2 [json_annotation source_span yaml] - chewie 0.12.0 [video_player cupertino_icons wakelock flutter] - chewie_audio 1.1.1 [video_player cupertino_icons flutter] - cli_util 0.2.0 [path] - clock 1.1.0-nullsafety.1 - code_builder 3.5.0 [built_collection built_value collection matcher meta] - collection 1.15.0-nullsafety.3 - connectivity_for_web 0.3.1+4 [connectivity_platform_interface flutter_web_plugins flutter] - connectivity_macos 0.1.0+7 [flutter] - connectivity_platform_interface 1.0.6 [flutter meta plugin_platform_interface] - convert 2.1.1 [charcode typed_data] - coverage 0.14.2 [args logging package_config path source_maps stack_trace vm_service] - crypto 2.1.5 [collection convert typed_data] - css_colors 1.0.2 [flutter] - csslib 0.16.2 [source_span] - cupertino_icons 1.0.0 - dart_style 1.3.10 [analyzer args path source_span] - device_info_platform_interface 1.0.1 [flutter meta plugin_platform_interface] - fake_async 1.2.0-nullsafety.1 [clock collection] - ffi 0.1.3 - file 6.0.0-nullsafety.2 [meta path] - firebase 7.3.3 [http http_parser js] - firebase_analytics_platform_interface 1.0.3 [flutter meta] - firebase_analytics_web 0.1.1 [flutter flutter_web_plugins firebase firebase_analytics_platform_interface meta] - firebase_auth_platform_interface 3.0.1 [flutter meta firebase_core plugin_platform_interface] - firebase_auth_web 0.3.2+6 [flutter flutter_web_plugins meta http_parser intl firebase_core firebase_core_web firebase_auth_platform_interface js] - firebase_core_platform_interface 3.0.1 [flutter meta plugin_platform_interface quiver] - firebase_core_web 0.2.1+3 [firebase_core_platform_interface flutter flutter_web_plugins meta js] - firebase_crashlytics_platform_interface 1.1.6 [flutter meta collection firebase_core plugin_platform_interface] - firebase_messaging_platform_interface 1.0.0-dev.10 [flutter meta firebase_core plugin_platform_interface] - firebase_messaging_web 0.1.0-dev.5 [flutter flutter_web_plugins meta firebase_core firebase_core_web firebase_messaging_platform_interface js service_worker] - firebase_storage_platform_interface 1.0.4 [flutter meta collection firebase_core plugin_platform_interface] - firebase_storage_web 0.1.1+3 [async crypto firebase_core firebase_core_web firebase_storage_platform_interface flutter flutter_web_plugins http js meta] - flutter_blurhash 0.5.0 [flutter meta] - flutter_cache_manager 2.0.0 [flutter path_provider uuid http path sqflite pedantic clock file rxdart] - flutter_keyboard_visibility 4.0.2 [meta flutter_keyboard_visibility_platform_interface flutter_keyboard_visibility_web flutter] - flutter_keyboard_visibility_platform_interface 1.0.1 [flutter meta plugin_platform_interface] - flutter_keyboard_visibility_web 1.0.1 [flutter_keyboard_visibility_platform_interface flutter_web_plugins flutter] - flutter_local_notifications_platform_interface 2.0.0+1 [flutter plugin_platform_interface] - flutter_pdfview 1.0.3+8 [flutter] - flutter_plugin_android_lifecycle 1.0.11 [flutter] - flutter_sound_platform_interface 6.4.5+1 [flutter meta plugin_platform_interface] - flutter_sound_web 6.4.5+1 [flutter_sound_platform_interface flutter flutter_web_plugins meta js] - flutter_spinkit 4.1.2+1 [flutter] - flutter_web_plugins 0.0.0 [flutter characters collection meta typed_data vector_math] - fuchsia_remote_debug_protocol 0.0.0 [json_rpc_2 process web_socket_channel flutter_test flutter_driver archive args async boolean_selector charcode clock collection convert crypto fake_async file matcher meta path platform pub_semver source_span stack_trace stream_channel string_scanner sync_http term_glyph test_api typed_data vector_math vm_service_client webdriver] - glob 1.2.0 [async collection node_io path pedantic string_scanner] - graphs 0.2.0 - html 0.14.0+4 [csslib source_span] - http_multi_server 2.2.0 [async] - http_parser 3.1.4 [charcode collection source_span string_scanner typed_data] - import_js_library 1.0.2 [flutter html flutter_web_plugins js] - io 0.3.4 [charcode meta path string_scanner] - js 0.6.3-nullsafety.2 - json_annotation 3.1.1 - json_rpc_2 2.2.2 [stack_trace stream_channel] - logger 0.9.4 - logging 0.11.4 - matcher 0.12.10-nullsafety.1 [stack_trace] - meta 1.3.0-nullsafety.3 - mime 0.9.7 - nested 0.0.4 [flutter] - node_interop 1.2.1 [js] - node_io 1.1.1 [node_interop path] - node_preamble 1.4.12 - octo_image 0.3.0 [flutter flutter_blurhash] - package_config 1.9.3 [path charcode] - path 1.8.0-nullsafety.1 - path_drawing 0.4.1+1 [vector_math meta path_parsing flutter] - path_parsing 0.1.4 [vector_math meta] - path_provider_linux 0.0.1+2 [path xdg_directories path_provider_platform_interface flutter] - path_provider_macos 0.0.4+6 [flutter] - path_provider_platform_interface 1.0.4 [flutter meta platform plugin_platform_interface] - path_provider_windows 0.0.4+3 [path_provider_platform_interface meta path flutter ffi win32] - pedantic 1.10.0-nullsafety.2 - permission_handler_platform_interface 2.0.1 [flutter meta plugin_platform_interface] - petitparser 3.1.0 [meta] - platform 3.0.0-nullsafety.2 - plugin_platform_interface 1.0.3 [meta] - pool 1.5.0-nullsafety.2 [async stack_trace] - process 4.0.0-nullsafety.2 [file path platform] - provider 4.3.2+2 [flutter nested collection] - pub_semver 1.4.4 [collection] - pubspec_parse 0.1.5 [checked_yaml json_annotation pub_semver yaml] - quiver 2.1.5 [matcher meta] - recase 3.0.1 - service_worker 0.2.4 [js] - shelf 0.7.9 [async collection http_parser path stack_trace stream_channel] - shelf_packages_handler 2.0.0 [path shelf shelf_static] - shelf_static 0.2.8 [convert http_parser mime path shelf] - shelf_web_socket 0.2.3 [shelf web_socket_channel stream_channel] - sky_engine 0.0.99 - source_gen 0.9.8 [analyzer async build dart_style glob meta path pedantic source_span] - source_map_stack_trace 2.1.0-nullsafety.3 [path stack_trace source_maps] - source_maps 0.10.10-nullsafety.2 [source_span] - source_span 1.8.0-nullsafety.2 [charcode collection path term_glyph] - sqflite_common 1.0.2+1 [synchronized path meta] - sqflite_common_ffi 1.1.1 [sqlite3 sqflite_common synchronized path meta] - sqlite3 0.1.8 [collection ffi meta] - stack_trace 1.10.0-nullsafety.1 [path] - stream_channel 2.1.0-nullsafety.1 [async] - stream_transform 1.2.0 - string_scanner 1.1.0-nullsafety.1 [charcode source_span] - sync_http 0.2.0 - synchronized 2.2.0+2 - term_glyph 1.2.0-nullsafety.1 - test_api 0.2.19-nullsafety.2 [async boolean_selector collection meta path source_span stack_trace stream_channel string_scanner term_glyph matcher] - test_core 0.3.12-nullsafety.5 [analyzer async args boolean_selector collection coverage glob io meta package_config path pedantic pool source_map_stack_trace source_maps source_span stack_trace stream_channel vm_service yaml matcher test_api] - timezone 0.5.9 [path] - timing 0.1.1+2 [json_annotation] - typed_data 1.3.0-nullsafety.3 [collection] - universal_io 1.0.1 [meta zone_local] - url_launcher_linux 0.0.1+4 [flutter] - url_launcher_macos 0.0.1+9 [flutter] - url_launcher_platform_interface 1.0.9 [flutter meta plugin_platform_interface] - url_launcher_web 0.1.5+1 [url_launcher_platform_interface flutter flutter_web_plugins meta] - url_launcher_windows 0.0.1+3 [flutter] - vector_math 2.1.0-nullsafety.3 - vibration_web 1.6.2 [flutter flutter_web_plugins] - video_player_platform_interface 2.2.0 [flutter meta] - video_player_web 0.1.4+1 [flutter flutter_web_plugins meta video_player_platform_interface] - vm_service 5.5.0 [meta] - vm_service_client 0.2.6+2 [async collection json_rpc_2 pub_semver source_span stack_trace stream_channel web_socket_channel] - wakelock 0.2.1+1 [flutter meta wakelock_platform_interface wakelock_web] - wakelock_platform_interface 0.1.0+1 [flutter meta] - wakelock_web 0.1.0+3 [flutter flutter_web_plugins import_js_library js wakelock_platform_interface] - watcher 0.9.7+15 [async path pedantic] - webdriver 2.1.2 [archive matcher path stack_trace sync_http] - webkit_inspection_protocol 0.7.4 [logging] - webview_flutter 1.0.7 [flutter] - win32 1.7.4 [ffi] - xdg_directories 0.1.2 [meta path process] - xml 4.5.1 [collection convert meta petitparser] - yaml 2.2.1 [charcode collection string_scanner source_span] - zone_local 0.1.2 ```

markusaksli-nc commented 3 years ago

Hi @yanivshaked The build is failing because of the deprecated imports in your native code. What exactly is it referencing and for what purpose? Thank you

yanivshaked commented 3 years ago

In Application.kt, I am referencing: import io.flutter.plugins.firebasemessaging.FlutterFirebaseMessagingService to call: FlutterFirebaseMessagingService.setPluginRegistrant(this)

FirebaseCloudMessagingPluginRegistrant.kt is:


import io.flutter.plugin.common.PluginRegistry
import io.flutter.plugins.firebasemessaging.FirebaseMessagingPlugin

class FirebaseCloudMessagingPluginRegistrant {
  companion object {
    fun registerWith(registry: PluginRegistry) {
      if (alreadyRegisteredWith(registry)) {
        return;
      }
      FirebaseMessagingPlugin.registerWith(registry.registrarFor("io.flutter.plugins.firebasemessaging.FirebaseMessagingPlugin"))
    }

    fun alreadyRegisteredWith(registry: PluginRegistry): Boolean {
      val key = FirebaseCloudMessagingPluginRegistrant::class.java.name
      if (registry.hasPlugin(key)) {
        return true
      }
      registry.registrarFor(key)
      return false
    }
  }
}

This was required for firebase_messaging: ^7.0.3 to work. Is that not needed anymore, and if so, are there any other registrations required in native code ?

Thanks!

markusaksli-nc commented 3 years ago

Oh in that case it is as simple as just removing this whole native workaround. You will also need to change the AndroidManifest.xml

<application android:name=".Application" ...>

part back to MainActivity.

Whenever you do large upgrades like this I recommend you take a look at the migration guide. In this case https://firebase.flutter.dev/docs/migration#messaging

Removed all manual native code changes that were originally required for integration - this plugin works out of the box once configured with Firebase & APNs.

Once you remove this it should work fine so I'm optimistically closing this as solved, let me know if you run into any other issues.

yanivshaked commented 3 years ago

Thanks!