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.52k stars 3.92k forks source link

Deprecated imperative apply of Flutter's Gradle plugins #13049

Closed ablbol closed 1 week ago

ablbol commented 1 week ago

Recently, I saw the following change about "Deprecated imperative apply of Flutter's Gradle plugins". Currently in my android/build.gradle, I have the following code (related to issue #12156):

// Add this block to use android BOM: 32.5.0
project.ext {
  set('FlutterFire', [
    FirebaseSDKVersion: "32.5.0",
  ])
}

The code was suggested by @russellwheatley .

The docs in the link above does not say where we should place this code. Keeping the code in android/build.gradle creates compilation error. Could someone please suggest a solution.

russellwheatley commented 1 week ago

@ablbol - I've just updated the firebase auth example which uses the declarative approach: https://github.com/firebase/flutterfire/blob/gradle-change-android-bom/packages/firebase_auth/firebase_auth/example/android/app/build.gradle#L29-L36

you can try on this branch: https://github.com/firebase/flutterfire/tree/gradle-change-android-bom

This is the build log:

Launching lib/main.dart on sdk gphone64 arm64 in debug mode...
Configured Firebase SDK Version: 32.5.0
✓ Built build/app/outputs/flutter-apk/app-debug.apk
Connecting to VM Service at ws://127.0.0.1:55640/_E5lQs3L8WY=/ws

It still works. Also - is there something that stops you from using the latest android BOM?

ablbol commented 1 week ago

Hi @russellwheatley, Thanks for your suggested solution. It did work. I was placing the code at the top of the build.gradle file which was causing compilation problem.

The reason I am still using this code is when I removed it, I was getting email-already-in-use exception when linking auth providers, even though I have the latest code of all the packages that I am using. (this is the same problem described in #12156 that we discussed before). I believe you told me back then I should not see the "email-already-in-use" exception in the latest packages. But that is not the case. This is how my pubspec.yaml looks like.

environment:
  sdk: '>=3.3.0 <4.0.0'
  flutter: 3.19.0

dependencies:
  android_id: ^0.4.0
  audio_waveforms: ^1.0.5
  badges: ^3.1.2
  cached_network_image: ^3.3.1
  carousel_slider: ^4.2.1
  cloud_firestore: ^5.0.2
  cloud_functions: ^5.0.2
  connectivity_plus: ^6.0.3
  crypto: ^3.0.3
  cupertino_icons: ^1.0.8
  device_info_plus: ^10.1.0
  dotted_border: ^2.1.0
  firebase_analytics: ^11.1.0
  firebase_app_check: ^0.3.0
  firebase_auth: ^5.1.1
  firebase_core: ^3.1.1
  firebase_crashlytics: ^4.0.2
  firebase_database: ^11.0.2
  firebase_messaging: ^15.0.2
  firebase_remote_config: ^5.0.2
  firebase_storage: ^12.1.0
  firebase_ui_firestore: ^1.6.4
  flash: ^3.1.1
  flutter:
    sdk: flutter
  flutter_dotenv: ^5.1.0
  flutter_facebook_auth: ^7.0.1
  flutter_hooks: ^0.20.5
  flutter_image_compress: ^2.3.0
  flutter_launcher_icons: ^0.13.1
  flutter_local_notifications: ^17.2.1
  flutter_localizations:
    sdk: flutter
  flutter_slidable: ^3.1.0
  flutter_svg: ^2.0.10
  geocoding: ^3.0.0
  geolocator: ^12.0.0
  go_router: ^14.2.0
  google_sign_in: ^6.2.1
  hooks_riverpod: ^2.5.1
  http: ^1.2.1
  image_cropper: ^7.1.0
  image_picker: ^1.1.2
  intl: ^0.19.0
  just_audio: ^0.9.38
  mask_text_input_formatter: ^2.9.0
  material_design_icons_flutter: ^7.0.7296
  open_mail_app: ^0.4.5
  package_info_plus: ^8.0.0
  path: ^1.9.0
  path_provider: ^2.1.3
  permission_handler: ^11.3.1
  photo_view: ^0.15.0
  purchases_flutter: ^6.29.4
  rate_my_app: ^2.2.0
  rxdart: ^0.27.7
  scrollable_positioned_list: ^0.3.8
  share_plus: ^9.0.0
  shared_preferences: ^2.2.3
  shimmer: ^3.0.0
  showcaseview: ^3.0.0
  stack_trace: ^1.11.1
  store_redirect: ^2.0.2
  swipe_to: ^1.0.6
  timeago: ^3.6.1
  url_launcher: ^6.3.0
  uuid: ^4.4.0
  webview_flutter: ^4.8.0

dev_dependencies:
  flutter_test:
    sdk: flutter
  flutter_web_plugins:
    sdk: flutter
  mocktail: ^1.0.4
  very_good_analysis: ^6.0.0
ablbol commented 1 week ago

Hi @russellwheatley, I changed my code so that linking of auth providers is done after the user logs in as suggested here. Also, I have enabled email enumeration protection as recommended. Finally, I used the following code in my android/app/build.grade:

// Add this block to use android BOM: 32.5.0
project.ext {
  set('FlutterFire', [
    FirebaseSDKVersion: "32.5.0",
  ])
}

Unfortunately, I am still getting email-already-in-use exception when linking auth providers.
I am afraid that enabling enumeration protection has caused this exception. Can you please suggest a solution to this.

russellwheatley commented 1 week ago

Thanks for confirming it works, @ablbol. I'm closing out as the issue is resolved. Please open a new issue outlining the problem with reproducible steps, thanks 🙏