Plugin error “PushNotifications” is not implemented on android

Hey, everybody. I had a problem with implementing push notifications with @capacitor/push-notifications. On android, I keep getting the error “PushNotifications” is not implemented on android.
This is my first time working with this plugin. I’ve tried deleting the android build several times and adding it again. I checked on different devices and emulators, but the same error everywhere.

I went through the official documentation several times to figure out what was wrong.

I got the file from firebase and put it in the right place.

I also changed the variables.gradle file according to the documentation. (I’ve tried it without these changes as well)

This was all the code I changed or added to the android build.

Below is the code for implementing the notification service on the home page for the test.

HomeView.vue

<template>
   <MainLayout :page-title="translate('HEADINGS.HOME')">
      <div></div>
   </MainLayout>
</template>

<script setup lang="ts">
import { onIonViewDidEnter, onIonViewWillLeave } from '@ionic/vue';
import { useAppI18n } from '@shared/i18n';
import MainLayout from '@shared/layouts/MainLayout.vue';
import { ref } from 'vue';
import { PushNotifications } from '@capacitor/push-notifications';
import { Capacitor } from '@capacitor/core';

const { translate } = useAppI18n();

const fcmTokens = ref([]);
const FCM_TOKENS_KEY = 'capacitorFcm/tokens';
let interval: any | null = null;

onIonViewDidEnter(async () => {
   if (Capacitor.isNativePlatform()) {
      await requestPermissions();
      addTokenListener();
      addErrorListener();
      addNotificationListener();

      interval = setInterval(() => {
         loadTokens();
      }, 2500);
   } else {
      console.warn('This functionality is only available on native platforms.');
   }
});

onIonViewWillLeave(() => {
   if (interval) {
      clearInterval(interval);
   }
});

const requestPermissions = async () => {
   try {
      const result = await PushNotifications.requestPermissions();
      if (result.receive === 'granted') {
         await PushNotifications.register();
      } else {
         throw new Error('Permission request failed!');
      }
   } catch (e) {
      console.error(e);
   }
};

const addTokenListener = () => {
   try {
      PushNotifications.addListener('registration', (token) => {
         const tokenValue = token?.value || '';
         if (tokenValue) {
            console.log('Token:', tokenValue);
            saveTokenToStorage(tokenValue);
            loadTokens();
         }
      });
   } catch (e) {
      console.error(e);
   }
};

const addErrorListener = () => {
   try {
      PushNotifications.addListener('registrationError', (e) => {
         console.error(e);
      });
   } catch (e) {
      console.error(e);
   }
};

const addNotificationListener = () => {
   try {
      PushNotifications.addListener('pushNotificationReceived', (notification) => {
         console.log('Push notification received:', notification);
      });
   } catch (e) {
      console.error(e);
   }
};

Capacitor.config

import type { CapacitorConfig } from '@capacitor/cli';

const config: CapacitorConfig = {
   appId: 'app.first.com',
   appName: 'first-app',
   webDir: 'dist',
   bundledWebRuntime: false,
   plugins: {
      PushNotifications: {
         presentationOptions: ['alert', 'badge', 'sound']
      }
   }
};

export default config;

Package.json

"dependencies": {
    "@capacitor/android": "6.1.0",
    "@capacitor/app": "6.0.0",
    "@capacitor/core": "^6.1.2",
    "@capacitor/haptics": "6.0.0",
    "@capacitor/ios": "6.1.0",
    "@capacitor/keyboard": "6.0.1",
    "@capacitor/push-notifications": "^6.0.2",
    "@capacitor/status-bar": "6.0.0",
    "@ionic/vue": "^8.2.6",
    "@ionic/vue-router": "^8.2.6",
    "@vee-validate/yup": "^4.13.1",
    "axios": "^1.7.2",
    "firebase": "^10.13.2",
    "ionicons": "^7.0.0",
    "localforage": "^1.10.0",
    "moment": "^2.30.1",
    "pinia": "^2.1.7",
    "vee-validate": "^4.13.1",
    "vue": "^3.3.0",
    "vue-advanced-cropper": "^2.8.9",
    "vue-i18n": "9",
    "vue-router": "^4.2.0",
    "vue-toastification": "^2.0.0-rc.5",
    "yup": "^1.4.0",
    "yup-phone": "^1.3.2"
  },

Perhaps I need to add or change something to make it work?

Try going through these steps - Troubleshooting Android Issues | Capacitor Documentation