Understanding Flutter Dependency and Build.gradle relationship

Viewed 219

I'm following this guide on adding Firebase Messaging to my simple Flutter app. Within the guide it states to add the following dependency to [app-name]/android/app/build.gradle:

implementation 'com.google.firebase:firebase-messaging:<latest_version>'

It all works fine. But i'm wondering why must one do this when the required flutter plugin "firebase_messaging: ^7.0.3", which is already added as a dependency within the flutter pubspec.yaml file, has already stated within its own build.gradle file the following:

implementation platform("com.google.firebase:firebase-bom:${getRootProjectExtOrCoreProperty("FirebaseSDKVersion", firebaseCoreProject)}")
implementation 'com.google.firebase:firebase-messaging'

I, of course removed the line within [app-name]/android/app/build.gradle to see what would happen and got the following error message:

*Application.java:14: error: cannot access FirebaseMessagingService
        FlutterFirebaseMessagingService.setPluginRegistrant(this);
                                       ^
class file for com.google.firebase.messaging.FirebaseMessagingService not found*

So is the rationale then whatever is a dependency stated within a Flutter plugin means it is only scoped within the flutter application it is attached to (everything within the LIB folder)? And if i make any changes outside this area (ie. within the root Android folder then i must deal with build.gradle and such?

0 Answers
Related