I can't get my geolocation from my Android device with capacitor

I’m building an app and I’m trying to access my location on my test devcie(deploy to device) or my virtual devices. Both don’t work. The only thing that works, is asking for permission for location usage and that is it. I get a alert ‘Current position:’ alert, but no latitude.

I’m not sure if my problem is capacitor or Framework7 related.

I added the following things to the Android environment:

Android/app/build.gradle

implementation "com.google.android.gms:play-services-location:$playServicesLocationVersion"

Android/app/variables.gradle

playServicesLocationVersion = '17.1.0'

Android/app/src/main/AndroidManifest.xml

<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.FOREGROUND_SERVICE"/>
<uses-feature android:name="android.hardware.location.gps" />

  <service android:name="io.framework7.myapp.MainActivity"
            android:foregroundServiceType="location"></service>

I’m not sure that service android:name=“io.framework7.myapp.MainActivity” is correct.

In my app.js self:

// requestPermissions
async function requestPermissions() {
    const permResult = await Geolocation.requestPermissions().catch(err => {
        console.error(err);
    });
}

// get location and alert the latitude
const printCurrentPosition = async () => {
    const coordinates = await Geolocation.getCurrentPosition().catch(err => {
        console.error(err);
    });
    alert('Current position:', coordinates.coords.latitude);
};

// checkPermissions, if necessary ask permissions and get currentPosition
function checkPermissions() {
    Geolocation.checkPermissions().then(data => {
        if (data.location == 'prompt' || data.location == 'prompt-with-rationale') {
            console.log(data.location);
            requestPermissions();
        } else if (data.location == 'granted') {
            console.log('granted ? ' + data.location);
            printCurrentPosition()
        } else {
            console.log(data.location);
            alert('You didnt give permission to use your location.');
            requestPermissions();
        }
    }).catch(err => {
        console.error(err);
    });
}

This is my minimal project:

Can Someone tell what I’m doing wrong?