Ionic Native Geolocation – Error getting location (Android)

I was literally scratching my head for the last few days to figure out why my codes couldn’t read geolocation values (latitude and longitude).

import { Geolocation } from '@ionic-native/geolocation';
...
constructor(private geolocation: Geolocation) {}
...
this.geolocation.getCurrentPosition().then((resp) => {
// resp.coords.latitude
// resp.coords.longitude
}).catch((error) => {
console.log('Error getting location', error);
});

let watch = this.geolocation.watchPosition();
watch.subscribe((data) => {
// data can be a set of coordinates, or an error (if an error occurred).
// data.coords.latitude
// data.coords.longitude
});

Solution:
You’ll have to insert the following lines into your AndroidManifest.xml and rebuild your app:

;

The lines ask for permission from Android to let the app reads location of the device.