Gradle Build Failing After Adding Firebase_messaging Plugin

After adding the firebase_messaging plugin v5.1.2 my app fails to build, but every time I remove it, the app builds normally, all I get is one red error line that says: Finished with error: Gradle task assembleDebug failed with exit code 1

I already tried to migrate my app to android X but this didn't help, tried the dex but nothing helpful again, also I tried avoiding android x and an use older version of the plugin but didn't work. (used v2.1.0 that's listed in the android X migration page).

These are all the plugins that I use in my app, maybe there is a conflict between them ?

firebase_core: ^0.4.0+6
firebase_auth: ^0.11.1+8
google_sign_in: ^4.0.4
cloud_firestore: ^0.12.7
firebase_storage: ^3.0.5
firebase_messaging: ^5.1.2
flutter_bloc: ^0.20.0
equatable: ^0.3.0
http: ^0.12.0+2
shared_preferences: ^0.5.3+4
image_picker: ^0.6.1
image_cropper: ^1.0.2
cached_network_image: ^1.1.1
intl: ^0.15.8

My end goal is to get notifications in my app from firebase

Edit: I created a new project with firebase_messaging being the only plugin in the project, and it worked! BUT as soon as I added the other libraries same problem again



the answer is on GitHub, hope it helps