0

I'm developing an app on android that depends heavily on the function of the gps plugin, but after to 2 calls to the gps this stops working. I need to open google maps in order to make the plugin work again.

I'm testing on samsung J1 and huawei G5 (android 5.1.1), cordova v7.0.0 and geolocation plugin version 2.4.2

2 Answers2

0

I found the solution in another question, check it here

thanks to user2147549, all credits to him.

this is what work in my case:

on cordova v5.3.3,you need to do this:

1、cordova plugin remove cordova-plugin-geolocation

2、cordova plugin add cordova-plugin-geolocation

3、copy your cordova-plugin-geolocation directory in your plguins dir to e:\

4、edit plugin.xml , add this:

<js-module src="www/Coordinates.js" name="Coordinates">
    <clobbers target="Coordinates" />
</js-module>

<js-module src="www/PositionError.js" name="PositionError">
    <clobbers target="PositionError" />
</js-module>

<js-module src="www/Position.js" name="Position">
    <clobbers target="Position" />
</js-module>

<js-module src="www/geolocation.js" name="geolocation">
    <clobbers target="navigator.geolocation" />
</js-module>

<config-file target="res/xml/config.xml" parent="/*">
    <feature name="Geolocation">
        <param name="android-package" value="org.apache.cordova.geolocation.GeoBroker"/>
    </feature>
</config-file>

<config-file target="AndroidManifest.xml" parent="/*">
    <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
    <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
    <uses-permission android:name="android.permission.ACCESS_LOCATION_EXTRA_COMMANDS" />
</config-file>

5、cordova plugin remove cordova-plugin-geolocation

6、cordova plugin add e:\cordova-plugin-geolocation

7、cordova run android now, I got gps position well. thanks for WuZhonghua.

0

Turns out that this problem can be solved by using an older version of the plugin.

In my case I only need the cordova app to work on android so thats no a problem.

you need to add gps plugin to your proyect like this:

cordova plugin add org.apache.cordova.geolocation@0.3.6