Problem using geolocation getCurrentLocation


I’m trying to get my current location. I have seen a couple of examples and can’t seem to find out what I’m doing wrong.


JS: Error: Cannot read property ‘GoogleApiAvailability’ of undefined


var geolocation = require("nativescript-geolocation");
exports.currentLocation = function() {  
    if (!geolocation.isEnabled()) {
        alert("You need to Enable GeoLocation!")

    geolocation.getCurrentLocation( {timeout: 5000} )
        .then(function (location) {
        }, function (e) {
            console.log("Error: " + e.message);


I believe you are using a real device for testing. Did you try a clean build after installing the module, make sure all dependencies are installed?


Hi I am using an Android Emulator.
Details for emulator:
Name: Nexus5_API
CPU/ABI: Google APIs Intel Atom (x86)
Path: C:\Users\\avd\Nexus5_API.avd
Target: google_apis [Google APIs] (API level 27)
Skin: nexus_5x
SD Card: 100 MiB
hw.dPad: no
hw.lcd.height: 1920 full
hw.accelerometer: yes Nexus 5X
vm.heapSize: 256
skin.dynamic: yes
hw.device.manufacturer: Google
hw.lcd.width: 1080
hw.gps: yes
hw.initialOrientation: Portrait
image.androidVersion.api: 27
hw.audioInput: yes
image.sysdir.1: system-images\android-27\google_apis\x86 google_apis
showDeviceFrame: yes none
hw.mainKeys: no
AvdId: Nexus5_API none
hw.lcd.density: 420
avd.ini.displayname: Nexus5 API
hw.gpu.mode: auto
hw.device.hash2: MD5:bc5032b2a871da511332401af3ac6bb0
hw.ramSize: 1536
hw.trackBall: no
PlayStore.enabled: false
fastboot.forceColdBoot: no
hw.battery: yes
hw.sdCard: no
tag.display: Google APIs none
hw.keyboard: no
hw.sensors.proximity: yes
disk.dataPartition.size: 200M
hw.sensors.orientation: yes
avd.ini.encoding: UTF-8
hw.gpu.enabled: yes


I don’t think Android emulators support GPS / has required Google Play libraries installed. You need a real device.


I used my actual android phone. Still got the same error.


Did you manage to solve this?


as @manojdcoder mentioned
do a “tns platform clean android”