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.63k stars 3.95k forks source link

🐛 Firebase Messaging fails version solving and dev version fails generatePlugin Registrant #4642

Closed DeanPack closed 3 years ago

DeanPack commented 3 years ago

Bug report

I've upgraded all my firebase packages today, and I had to upgrade to version 8.0.0-dev.13 because the highest stable version fails version solving with the other new stable firebase packages. In Application.Java, I have:

package com.halloglobal.flutterapp.hallo;

import io.flutter.app.FlutterApplication;
import io.flutter.plugin.common.PluginRegistry;
import io.flutter.plugin.common.PluginRegistry.PluginRegistrantCallback;
import io.flutter.plugins.GeneratedPluginRegistrant;
import io.flutter.plugins.firebasemessaging.FlutterFirebaseMessagingService;
import io.flutter.plugins.firebasemessaging.FirebaseMessagingPlugin;
import io.flutter.view.FlutterMain;

public class Application extends FlutterApplication implements PluginRegistrantCallback {
@override
public void onCreate() {
super.onCreate();
FlutterFirebaseMessagingService.setPluginRegistrant(this);
}
@override
public void registerWith(PluginRegistry registry) {
FirebaseMessagingPlugin.registerWith(registry.registrarFor("io.flutter.plugins.firebasemessaging.FirebaseMessagingPlugin"));
}
}

Which has worked fine in the past, but now with this new version, I get this error:

Note: Recompile with -Xlint:deprecation for details.
/Users/hallo/Documents/HalloMonoRepo/hallo/android/app/src/main/java/com/halloglobal/flutterapp/hallo/Application.java:7: error: package io.flutter.plugins.firebasemessaging does not exist
import io.flutter.plugins.firebasemessaging.FlutterFirebaseMessagingService;
^
/Users/hallo/Documents/HalloMonoRepo/hallo/android/app/src/main/java/com/halloglobal/flutterapp/hallo/Application.java:8: error: package io.flutter.plugins.firebasemessaging does not exist
import io.flutter.plugins.firebasemessaging.FirebaseMessagingPlugin;

How do I need to change my Application.java to work with the new version?

here is my pubspec.yaml

name: hallo
description: Practice English with friends.

# The following defines the version and build number for your application.
# A version number is three numbers separated by dots, like 1.2.43
# followed by an optional build number separated by a +.
# Both the version and the builder number may be overridden in flutter
# build by specifying --build-name and --build-number, respectively.
# Read more about versioning at semver.org.
# version: 1.0.0+1
environment:
  sdk: ">=2.3.0 <3.0.0"

dependencies:
  flutter:
    sdk: flutter
  flutter_localizations:
    sdk: flutter
  audio_recorder:
    git: https://github.com/sujindra-kodiary/audio_recorder
  audioplayer:
    git: https://github.com/halloglobal/audioplayer
  audio_service: ^0.16.1
  facebook_standard_events:
    git: https://github.com/halloglobal/facebook_standard_events.git
  flutter_keyboard_visibility:
    git: https://github.com/halloglobal/flutter_keyboard_visibility
  flutter_native_image:
    git:
      url: https://github.com/btastic/flutter_native_image.git
      ref: f4d9b4fadfb199cfbd75cabc8a1ac31a7bf43de5
  image_downloader:
    git: https://github.com/halloglobal/image_downloader
  save_in_gallery:
    git: https://github.com/sujindra-kodiary/save_in_gallery
  agora_rtc_engine: 3.2.1
  app_review: ^2.0.1
  apple_sign_in: ^0.1.0
  built_collection: ">=2.0.0 <5.0.0"
  built_value: ^7.1.0
  camera: ^0.5.8+11
  carousel_slider: ^2.2.1
  chewie: ^0.10.4
  cloud_firestore: 0.16.0
  cloud_functions: 0.9.0
  connectivity: ^2.0.0
  contacts_service: ^0.4.6
  cupertino_icons: ^1.0.0
  devicelocale: ^0.3.1
  dots_indicator: ^1.2.0
  downloads_path_provider: ^0.1.0
  dynamic_theme: ^1.0.1
  file_picker: ^2.0.12
  firebase_analytics: ^7.0.0
  firebase_auth: 0.20.0
  firebase_core: ^0.7.0
  firebase_database: ^6.0.0
  firebase_dynamic_links: ^0.7.0
  firebase_messaging: ^8.0.0-dev.13
  firebase_remote_config: ^0.6.0
  firebase_storage: ^7.0.0
  flutter_app_badger: ^1.1.2
  flutter_colorpicker: ^0.3.2
  flutter_cupertino_date_picker:
    git: https://github.com/daveleenew/flutter-cupertino-date-picker.git
  flutter_cupertino_localizations: ^1.0.1
  flutter_linkify: ^4.0.2
  flutter_parsed_text: ^1.2.3
  flutter_redux: ^0.7.0
  flutter_slidable: ^0.5.4
  flutter_sms: 2.1.1
  flutter_svg: ^0.19.1
  flutter_time_picker_spinner: ^1.0.6+1
  flutter_webview_plugin: ^0.3.10+1
  fluttertoast: ^7.1.1
  geolocator: ^6.1.6
  geocoding: ^1.0.5
  get_ip: ^0.4.0
  google_sign_in: ^4.3.0
  http: ^0.12.0+4
  image_cropper: ^1.3.1
  image_picker: ^0.6.7+11
  in_app_purchase: ^0.3.4
  intl: ^0.16.0
  overlay_support: ^1.0.1
  package_info: ^0.4.0+3
  path_provider: ^1.6.18
  permission_handler: ^5.0.1+1
  photo_view: ^0.10.0
  provider: ^4.3.1
  redux: ^4.0.0
  redux_dev_tools: ^0.5.0
  redux_epics: ^0.14.0
  redux_logging: ^0.4.0
  redux_thunk: ^0.3.0
  rxdart: ^0.24.0
  scoped_model: ^1.0.1
  sentry: ^3.0.1
  share: ^0.6.0+1
  shimmer: ^1.1.1
  showcaseview: ^0.1.3
  simple_pdf_viewer: ^0.2.2
  streaming_shared_preferences: ^1.0.1
  stripe_payment: ^1.0.0
  timeago: ^2.0.9
  trust_fall: ^1.0.4
  url_launcher: ^5.0.2
  uuid: ^2.2.0
  vibration: ^1.7.2
  video_player: ^1.0.0
  wakelock: ^0.2.0
  web_socket_channel: ^1.0.8
  native_screenshot: 
    git: 
      url: https://gitlab.com/sujindra2014/native_screenshot
      ref: b271cbbdc1b8698dadfb0773b840ccc8bdf52c6e
  cached_network_image: ^2.3.0
  firebase_crashlytics: ^0.4.0
  flutter_staggered_grid_view: ^0.3.2
  flutter_sticky_header: ^0.4.5
dev_dependencies:
  flutter_test:
    sdk: flutter
  build_runner: ^1.10.0
  # test: ^1.5.1
  built_value_generator: ^7.1.0
  flutter_launcher_icons: ^0.7.0
  intl_translation: ^0.17.0

flutter_icons:
  adaptive_icon_background: "#ffffff"
  android: true
  ios: true
  image_path_android: "assets/app_icon.png"
  image_path_ios: "assets/app_icon.png"
# For information on the generic Dart part of this file, see the
# following page: https://www.dartlang.org/tools/pub/pubspec
# The following section is specific to Flutter.
flutter:
  assets:
    - assets/nav/
    - assets/flags/
    - assets/icons/
    - assets/icons/2x/
    - assets/icons/3x/
    - assets/instamatch/
    - assets/logos/
    - assets/onboarding/
    - assets/profile/
    - assets/social/
    - assets/gamification/
    - assets/schedules/
    - assets/

  # The following line ensures that the Material Icons font is
  # included with your application, so that you can use the icons in
  # the material Icons class.
  uses-material-design: true

  # An image asset can refer to one or more resolution-specific "variants", see
  # https://flutter.io/assets-and-images/#resolution-aware.
  # For details regarding adding assets from package dependencies, see
  # https://flutter.io/assets-and-images/#from-packages
  # To add custom fonts to your application, add a fonts section here,
  # in this "flutter" section. Each entry in this list should have a
  # "family" key with the font family name, and a "fonts" key with a
  # list giving the asset and other descriptors for the font. For
  # example:
  fonts:
    - family: Quicksand
      fonts:
        - asset: assets/fonts/Quicksand-Light.ttf
          weight: 300
        - asset: assets/fonts/Quicksand-Regular.ttf
          weight: 400
        - asset: assets/fonts/Quicksand-Medium.ttf
          weight: 500
        - asset: assets/fonts/Quicksand-SemiBold.ttf
          weight: 600
        - asset: assets/fonts/Quicksand-Bold.ttf
          weight: 700
  #   - family: Trajan Pro
  #     fonts:
  #       - asset: fonts/TrajanPro.ttf
  #       - asset: fonts/TrajanPro_Bold.ttf
  #         weight: 700
  #
  # For details regarding fonts from package dependencies,
  # see https://flutter.io/custom-fonts/#from-packages

Flutter doctor

Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, 1.22.5, on Mac OS X 10.15.6 19G2021 darwin-x64, locale en-US)

[✓] Android toolchain - develop for Android devices (Android SDK version 29.0.2)
[✓] Xcode - develop for iOS and macOS (Xcode 12.3)
[✓] Android Studio (version 3.4)
[✓] VS Code (version 1.52.1)
[✓] Connected device (1 available)

• No issues found!
markusaksli-nc commented 3 years ago

Hi @DeanPack If you are using the messaging dev version you no longer need the Application.java hack. As stated in https://firebase.flutter.dev/docs/messaging/overview#3-android-integration

If you are using Flutter Android Embedding V2 (Flutter Version >= 1.12) then no additional integration steps are required for Android.

You can just remove this workaround. Thank you

DeanPack commented 3 years ago

Thank you, that worked!