I am trying to add notification services to my app using FCM and tutorial given on https://www.simplifiedcoding.net/firebase-cloud-messaging-android/ Everything has done and
What finally saved me:
In android studio, switch to Project view instead of Android view. Delete .gradle folderm and also the gradle.properties file. Clean the project. Sync gradle again.
I have no clue why this worked. Deleting only the .gradle folder didn't do the job and the newly made gradle.properties is exactly the same as the old one! But my issue is fixed.