Geolocation not working

I am trying to get my location on Android just like in the example in the docs:

import { Plugins } from '@capacitor/core';

const { Geolocation } = Plugins;

class GeolocationExample {
  async getCurrentPosition() {
    const coordinates = await Geolocation.getCurrentPosition();
    console.log('Current', coordinates);

But I am getting this error:

result Geolocation.getCurrentPosition (#55356864)
capacitor-runtime.js:81 {message: "location unavailable"}

I have gps enabled and i also gave the permissions